Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how can i make this for loop repeat if a player dies?

This is the loop i want to repeat on a players death:

wait(1)
for i = 0,10,1 do
	Lava.Size = Vector3.new(380.5,0.5+i,2318)
	wait(.2)
end

2 answers

✓ Accepted answer

Try using this function and add your loop to it

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			print(player.Name .. " has died!")
		end)
	end)
end)

2 comments

0

where do I add the loop?

0

Where the print is.

game.Players.PlayerAdded:connect(function(plr) for i = 0,10,1 do Lava.Size = Vector3.new(380.5,0.5+i,2318) wait(.2) end end)

5 comments

0

does this make the loop start from the beginning?

0

it runs the loop when the player dies

0

how do I make it run first and then it runs again if a player dies

0

oh! let me edit it

0

parent it inside of starterpack. put it in a normal script

This discussion is preserved as it was. New answers, comments, and votes are closed.