ProximityPrompt Triggered Fail

Hello,
I try to associate proximityPrompt to the opening of a door. For that I use a local script which when the proximityprompt is triggered calls the script to open the door. But when I trigger nothing even happens the print in the local script. The reason must be obvious and stupid, but no matter how hard I look, I’m stuck. There are no error messages

Thank you !

Is the Hinge part in workspace? If so, that’s your issue, LocalScripts do not work in workspace, you either have to put the localscript somewhere it does work, like StarterPlayerScripts and add a sanity check in your triggered event to make it so it only works for the client that triggered it or just change your script to a regular script and change the code around

1 Like

Oh i see thank you im making test, i keep you posted

1 Like

I made that in playerscript its working ! thank you again !

local RS = game:GetService(“ReplicatedStorage”)
local Events = RS.Events
local event = Events.HingeDoorEvent

for i, v in ipairs (workspace.Castle:GetDescendants())do

if v.Name == ("DoorProxPrompt")then
	
	v.Triggered:Connect(function()
		print("Triggered")
		local door = v.Parent
event:FireServer(door)

end)

end

end

1 Like

I would recommend doign this

local RS = game:GetService("ReplicatedStorage")
local Events = RS.Events
local event = Events.HingeDoorEvent
local localPlayer = game:GetService("Players").LocalPlayer

for _, prompt in ipairs(workspace.Castle:GetDescendants()) do
	if v.Name ~= ("DoorProxPrompt") then continue end
		
	v.Triggered:Connect(function(plr)
		if plr ~= localPlayer then return end
		print("Triggered")
		local door = v.Parent
		event:FireServer(door)
	end)
end

Because the event will trigger for everyone because there is no sanity check involved, if one person triggers the prompt, everyone will fire the event

1 Like