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

How do I run a script after player respawns?

So I am trying to give the player tools (and change gui text) into their inventory. Since there are some conditions with tools and when the character respawns he doesn't get his tools back. How do I run a script after the players respawns?

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.PlayerGui.SideScreenGUI.Balance.Ribix.Text = player.leaderstats.ribix.Value
	player.PlayerGui.SideScreenGUI.Balance.Bobux.Text = player.leaderstats.bobux.Value
	if player.items.GoodRibixItem.Value == true then
		local gear2 = game.ServerStorage["Good Ribix generator"]
		gear2:Clone().Parent = player:WaitForChild("Backpack")
	else
		local gear = game.ServerStorage["Ribix generator"]
		gear:Clone().Parent = player:WaitForChild("Backpack")
	end
end)

for some reason it does not give any tool at all (there is no error message given) Thanks

1 answer

The event PlayerAdded fires only one time when a player joins. Use CharacterAdded on the Player. There's a example:

game.Players.PlayerAdded:Connect(function(player)
	
	--This event fires everytime the character gets added to the player
	player.CharacterAdded:Connect(function(char)
		--Here you can do whatever you want with the character
		
		
	end)
	
end)

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