The problem with this script is that it only runs once. Example: I die the first time everything works properly. Then, the second time I die nothing happens. I need help fixing it.


local respawnTime = 11.2
 
local Player = game.Players.LocalPlayer

Character = Player.Character

Players = game.Players

game.Workspace.Death3.humdeath:FireServer()  --game.Players.CharacterAutoLoads = false

Players.PlayerAdded:connect(function(Player)

	game.Workspace.Death2.humdeath:FireServer() -- load the character at the beginning of the game once

end)

local Humanoid = Character:FindFirstChild("Humanoid")
		if Humanoid then
			Humanoid.Died:connect(function()

               Player.PlayerGui:SetTopbarTransparency(0)
				
				Player.Backpack.Hit:Play()
				
				wait(0.15)
				
				Player.Backpack.Hit:Stop()
				
				game.Workspace.WhiteScreenclone.whiteclone:FireServer()
--game.ReplicatedFirst.WhiteScreen:Clone().Parent = Player.PlayerGui
				
				wait(0.2)
   
			 	Player.Backpack.EarRinging:Play()
 
				wait()
			
				--Character:Destroy()
			
				wait(respawnTime)
				
				
				game.Workspace.BlackScreenclone.blackclone:FireServer() --game.ReplicatedFirst.BlackScreen:Clone().Parent = Player.PlayerGui
				
				wait()
				
				for i = 1,0,-0.05 do
					
				wait(0.06)
					
				Player.PlayerGui.BlackScreen.Frame.BackgroundTransparency = i
						
				end
				
				Player.Backpack.Hit.TimePosition = 0 
				
				Player.Backpack.EarRinging.TimePosition = 0
				
				game.Workspace.Death2.humdeath:FireServer()
				
			end)	
		end





8 comments

0

Tbh.. What a mess

0

I'm just curious, where is this script located? Just inside the Workspace?

0

No, it's in the player's starter scripts

0

sorry I forgot to review it

0

I fixed it, I just had to put a loop on it facepalm

0

don't put a loop on it you dingus

0

can I just put a while loop on the whole script a put a repeat loop on the death function?

0

and the repeat loop will have a until humanoid.health == 0 on it. Is that fine or is there a better way to do this?