【问题标题】:Roblox ProximityPrompt activates everything for some reasonRoblox ProximityPrompt 出于某种原因激活了一切
【发布时间】:2021-08-11 21:49:46
【问题描述】:

有没有办法让 ROBLOX 接近提示仅在激活特定接近提示时才激活?这是我的代码。目前,如果任何提示被激活,它就会运行,但是我只想要一个接近提示来激活它。

script.Parent.ObjectText = script.Parent.Parent.Parent.Name
local ProximityPromptService = game:GetService("ProximityPromptService")
local label = script.Parent.Parent.Parent.Torso.SurfaceGui.TextLabel
local function typewrite(text,length)
    for i = 1,#text,1 do
        label.Text = string.sub(text,1,i)
        wait(length)
        script.Parent.Parent.DIALOGSOUND:Play()
    end
    wait(4)
    label.Text = " "
end

local function onPromptTriggered(promptObject, player)
        typewrite("hey there", 0.05)
end
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)


【问题讨论】:

    标签: roblox


    【解决方案1】:

    ProximityPromptService.PromptTriggered 信号提供作为回调中的第一个对象触发的特定提示。

    在您的代码中,您已经可以访问邻近提示对象,您只需要您的代码对其进行过滤并获取对您关心的邻近提示的引用。

    -- locate the proximity prompt in the workspace
    local specificPrompt = game.Workspace.SomeProximityPrompt
    
    local function onPromptTriggered(promptObject, player)
        -- escape if triggered from the wrong prompt
        if promptObject ~= specificPrompt then
            return
        end
    
        typewrite("hey there", 0.05)
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-31
      • 1970-01-01
      • 1970-01-01
      • 2010-11-02
      相关资源
      最近更新 更多