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

How can I make this code repeat every time a player dies?

I've tried this but it didn't work.

while wait(1) do
	local player = game:GetService("Players").LocalPlayer
	local humanoid  = player.Character.Humanoid
	
	if humanoid.Health == 0 then
		wait(6)
		mouse.KeyDown:Connect(function(key)
			if key == "e" then
				if mouse.Target then
					humanoidRoot.CFrame = CFrame.new(mouse.Hit.x,mouse.Hit.y + 5,mouse.Hit.z)
				end
			end
		end)
	end
end

4 comments

1

humanoid.Died:Connect(function()

0

That didn't work

0

if Died doesn't work, myb HealthChanged

0

Doesn't that work all the time even if the player dies and even without the humanoid.Health ==0?

1 answer

I would reckon highering the spawn location and putting a block on the spawn location, and the putting:

script.Parent.Touched:Connect(function(hit)
-- code here
end)

1 comment

0

I will try that

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