Trying to make an imagelabel move every time the player character dies.
But the script only does its job on one death.
Help?
local n = script.Parent player = game.Players.LocalPlayer character = player.Character or player.CharacterAdded:wait() humanoid = player.Character:WaitForChild("Humanoid") humanoid.Died:connect(function () wait(5) n.Position = n.Position - UDim2.new(0,-30,0,0) end)
Here is why: This is a GUI, and the script is a local script inside of it, correct? When the character dies, it will wait 5 seconds. In about 4 seconds, the character would respawn. Then, the next second, the Gui is moved. Seems like it would work, but the Gui would reset it's position when the player respawns. So therefore, it would seem like the function is only running once. You can stop this in several ways: Have a count IntValue somewhere in the player, that tells you how many times he has died or so, and adjust the position of the TextLabel accordingly. Example:
local n = script.Parent player = game.Players.LocalPlayer character = player.Character or player.CharacterAdded:wait() humanoid = player.Character:WaitForChild("Humanoid") local Times = player.Times -- Make the IntValue through another script humanoid.Died:connect(function () wait(5) Times.Value = Times.Value + 1-- Don't worry about this affecting FE, unless the position of your textlabel is crucial to the game and someone has a reason to exploit it. n.Position = n.Position - UDim2.new(0,-30*Times.Value,0,0) end)
Of course, that is only one way. You don't even have to follow it the same way, but the point is to have a count of how many times the player dies. The second way would be to adjust the Gui's settings so that it does not respawn, if it's an option. You can also keep track of where the position was prior to the respawn, and adjust that. Anyways, it shouldn't be difficult and if it turns out to be, feel free to post a question. Just think of the right way for your game