Brick = script.Parent Brick.Touched:connect(function(part) if part.Parent.Humanoid then if part.Parent.Humanoid.Health > 0 then wait(0.5) part.Parent:MoveTo(game.Workspace.EasyLobby.Position + Vector3.new(0,1,0)) local plr = game.Players:FindFirstChild(part.Parent.Name) game.ReplicatedStorage.Winners.Value = game.ReplicatedStorage.Winners.Value.." "..plr.Name end end end)
Hey guys I have a round-based game, and this script is inside of the part, where players touch it, they win
It works fine, but if someone wins, they're name will sometimes be printed more than once. I don't want to add a debounce in time because another player could step on the brick at the same time. Any ideas?
This is a simple mistake, what you did was make it to where it adds the players name every single time the player touches it, which is infinite times per second. What you need to do is add
if game.ReplicatedStorage.WinnersValue.Value ~= plr.Name then -- add the same script as before and it should work just fine. end
Hope I helped.
EDIT: The script must only be around changing the value of the WinnersValue, not the whole script.