ProximityPrompt shown/hidden events not working

image

ProximityPrompt style is set to custom. LocalScript:

script.Parent.PromptShown:Connect(function()
	script.Parent.Parent.BillboardGui.Enabled = true
end)

script.Parent.PromptHidden:Connect(function()
	script.Parent.Parent.BillboardGui.Enabled = false
end)

I’m not sure why this isn’t working, I’ve tried to set it up globally using the ProximityPromptService but that hasn’t worked either. I’ve read other DevForum posts and everything that I saw I’ve already tried. Print statements put inside these functions don’t run and I’m really not sure what’s wrong. Is there a beta feature I’m missing or is Roblox just being jank?

I don’t think there’s anything wrong with the code, can you export a model file and send it to me so I can have a look myself?

tape.rbxm (20.0 KB)
Sorry for the late response!

1 Like

Right, I forgot about the fact that LocalScripts don’t run in the workspace.
To fix this, you’ll need to use ProximityPromptService, and listen to the global PromptShown and PromptHidden event. Same goes for the server.
Add a tag (with the Tag Editor) to determine if the ProximityPrompt is from the tape (using CollectionService).
So something like:

-- SERVER (ServerScriptService)
local PPS = game:GetService("ProximityPromptService")
local CS = game:GetService("CollectionService")

PPS.PromptTriggered:Connect(function(prompt, player)
	if CS:HasTag(prompt,"TapePrompt") then
		prompt.Enabled = false
		prompt.Parent.Transparency = 1
	end
end)
-- CLIENT (StarterPlayerScripts)
local PPS = game:GetService("ProximityPromptService")
local CS = game:GetService("CollectionService")

PPS.PromptShown:Connect(function(prompt, inputType)
	if CS:HasTag(prompt,"TapePrompt") then
		prompt.Parent:FindFirstChildOfClass("BillboardGui").Enabled = true
	end
end)

PPS.PromptHidden:Connect(function(prompt, inputType)
	if CS:HasTag(prompt,"TapePrompt") then
		prompt.Parent:FindFirstChildOfClass("BillboardGui").Enabled = false
	end
end)

The tag must be called TapePrompt. If you want to change the name, you’ll have to change it in the scripts as well.

Yeah, that was it! Interesting. I’ve been using Studio since 2015 and somehow never knew LocalScripts didn’t run in the workspace. I’ll likely take a different approach than using tags, but I also never knew about CollectionService so I’d have to look into that as well.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.