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

How to modify it so that the tool is given again, after resetting/respawning?

local plr = game:GetService("Players")


game.Players.PlayerAdded:Connect(function(plr)
	local character = game.Workspace:WaitForChild(plr.Name)
  	  if plr.Name == "aprilsfooled" then
		print (plr.Name .. " , has spawned")
   	 local t = game.ServerStorage.Tools.Keycard:Clone()
 	   t.Parent = plr.Backpack

end
end)

2 answers

✓ Accepted answer

CharacterAdded I believe fires on a respawn and on join.

Ex.

local Name = "aprilsfooled"

game.Players[Name].CharacterAdded:Connect(function()
	-- your code --
end)

4 comments

0

Just want to know that you don’t have to do game.Players[plr.Name] when par has already been given to you. Also, there is no need to check for the player’s name, the connection is only for the given player.

0

@ankurbohra04 That is correct, I don't know what I was thinking. I'll fix the code.

0

@Benbebop aprilsfooled is not a valid member of Players

0

@aprilsfooled make sure that the name is exacly the same as your roblox name. If that doesnt work, run a test and look in the players then copy the name of your client. Paste it there and try it again.

local Players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(plr)
	
	plr.CharacterAdded:Connect(function(character)
		
		if plr.Name == "yourinvolvedplayer" then
			
			 print (plr.Name .. " , has spawned")

	    		 local t = game.ServerStorage.Tools.Keycard:Clone()
	       		 t.Parent = plr.Backpack
		end
	end)
	
end)	

I got it fixed. Thanks for the help though.

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