【问题标题】:How to get the Roblox Proximity to open a store Frame如何获得 Roblox Proximity 开店框架
【发布时间】:2022-01-24 21:13:57
【问题描述】:

我通读了 Roblox 开发者中心,了解如何使 ProximityPrompt 工作,我可以让它做某些事情,但我希望能够在游戏 gui 商店中打开一个。我找不到如何调用 Frame 以使其可见,也找不到如何让 Frame 寻找正确的触发器。

以下是我添加到 Frame localScript 中的内容

local prompt = game:GetService("ProximityPromptService")

local button = game.Workspace.MinerStore.ProximityPrompt.Triggered:WaitForChild()

local function prompt(PromptObject, player) 
    frame.Visible = not frame.Visible

这就是我的提示脚本显示的内容。

local frame = game.StarterGui.Miners:WaitForChild("Frame")

game.Workspace.MinerStore.ProximityPrompt.Triggered:Connect(function(player)
    --game.StarterGui.Miners.Frame:Connect(function(player)
    --  frame.Visible = not frame.Visible
    --end)
    
end)

我从开发者中心获得了所有这些权利,并试图将其变成我自己的,但由于我不明白的原因,两者没有联系。

【问题讨论】:

    标签: lua roblox proximity


    【解决方案1】:

    您注释掉的代码表明您犯了一个常见错误。放置在StarterGui 中的 UI 充当模板。当他们的角色生成时,它会被复制到每个玩家的PlayerGui 中。您似乎正在尝试修改 UI 模板,而不是特定玩家看到的实​​际 UI。

    由于可以在 LocalScript 中观察到 ProximityPrompt,因此您可以直接在 UI LocalScript 中侦听触发器。

    local prompt = game.Workspace.MinerStore.ProximityPrompt
    local frame = script.Parent
    
    prompt.Triggered:Connect(function()
        frame.Visible = true
    end)
    

    【讨论】:

    • 我能够让它与一些模组一起工作,以使其适用于我正在做的事情。谢谢。
    猜你喜欢
    • 2011-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-20
    • 1970-01-01
    • 2020-03-28
    • 2020-10-25
    • 2020-08-05
    相关资源
    最近更新 更多