How to make a script that will run a code when a player respawns?

i want to make a script that will check if a value inside a player is true, but the small brain i am i cant figure out how todo this. please help.

-BTW the path to check the value is game.Players.(WhoEver).PlayerValues.SpeedCoil.Value

-also “SpeedCoil” is the value, also its a BoolValue

2 Likes

For the i want to make a script that will check if a value inside a player is true, but the small brain i am i cant figure out how todo this. please help.
Here is an example of how to do it,
If the value is inside the player then just do it like this

if Player.PlayerValues.SpeedCoil.Value == true then
--your function
end

If the value is inside the character then like this

if Character.SpeedCoil.Value == true then
--your function
end

What you should do is check if the Characters Humanoid had died then repeating the “wait() until character” function till the character respawns then you execute the script

how would i check if humanoid has died?

Not sure if what you mean is the correct answer. The solution to this should just be a nested function.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
-- This code will run when the player respawns
end)
end)
1 Like

You can use:

Humanoid.Died:Connect(function()
	
end)

That runs when the humanoid health is 0 not when they respawn

Can’t you just put a script inside of StarterCharacterScripts?

thank you for helping! you are the second part of the solution btw, lol too bad i cant add two solutions