local player = game.Players.LocalPlayer local char = player.Character local storage = game:GetService("ReplicatedStorage") char.Humanoid.Died:Connect(function() for i,v in pairs(storage.Contestants:GetChildren()) do if v.Name == player.Name then v.Dead.Value = true end end end)
This script only works once, then never works again. It is a localscript in StarterGui and this happens in both studio and in-game. Help?
Okay. There are a few things that I notice, in which should be changed. The biggest is that you are locally changing the BoolValue, which wouldn't be a good idea if your game was to go into FE. Assuming that this script is to always run, this is simply the way I would do it:
--A server script in workspace local storage = game:GetService("ReplicatedStorage") game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() for index, child in pairs(storage.Contestants:GetChildren()) do if child.Name == player.Name then child.Dead.Value = true end end end) end) end) -- Expect typos because I didn't test this in studio, just typed it out here
What I changed: - I made this a server sided script that I'd use for a FE game -Got rid of single lettered variables - Probably made a script that works