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)
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.
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.
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)