Gui only opens once from proximity prompt

In this case, game.Lighting.plr.Value is the player character, and the whole thing works, but it only works once. After the 1st use of it, this script is useless.

	while game.Lighting.plr.Value == nil do
		task.wait()
	end
	plr = game.Lighting.plr.Value
	for r,x in pairs(game.Players:GetChildren()) do
		if x.Name == tostring(plr) then
			plr = x
		end
	end
	if plr:WaitForChild("PlayerGui").Math.Enabled == false then
		plr:WaitForChild("PlayerGui").Math.Enabled = true
	end
end

script.Parent.ProximityPrompt.PromptButtonHoldEnded:Connect(click)

No errors have been thrown

1 Like

You’re doing it on the server. Create a remote event that’ll fire to the client which will open the gui

I don’t think the player value inside of lighting is reliable. Is this using Roblox’s ProximityPrompt? If so, there is an argument in the Triggered event that provides the player instance.

2 Likes

I used to use it, but it sometimes returns nil, just does it when it feels like it so I have to be harsh in this case

1 Like

Oh, I see your issue now. You are setting the Enabled property to true, but it is being changed to false on the CLIENT, not the server. Therefore, the server still thinks it is true, and the if statement is not passed.

I suggest removing the if statement

1 Like

It was not there before (i.e 11 hours ago) when I first began troubleshooting the issue, this will not work

nonetheless going anyway

1 Like

Create a remote event in replicated storage, then update ur code to this. Noraml script


while game.Lighting.plr.Value == nil do
		task.wait()
	end
	plr = game.Lighting.plr.Value
	for r,x in pairs(game.Players:GetChildren()) do
		if x.Name == tostring(plr) then
			plr = x
		end
	end
         game.ReplicatedStorage.RemoteEvent:FireClient(plr)
end

script.Parent.ProximityPrompt.PromptButtonHoldEnded:Connect(click)

Local script in starter player scripts

game.ReplicatedStorage:WaitForChild(“RemoteEvent”).OnClientEvent:Connect(function()
PATHTOUI.Enabled = true
end)
3 Likes

It should work, give it a try.

2 Likes

This works, thanks! Now I can sleep at 03:30… wait i still have to sort out a fridge opening…

Glad i could help!!!

1 Like

use proximityprompt.Triggered instead of script.Parent.ProximityPrompt.PromptButtonHoldEnded, it works better

1 Like

Done as well, now I know how that actually works thank god.

Thank you!!!