"CharacterAdded" will not work at all

I want to detect when the player respawns to change their walkspeed and add a sword to their backpack.

I can’t detect when the player respawns. I’ve been told “CharacterAdded” fires when a player respawns, but it will not fire under any circumstances. Humanoid.Died:Connect(function() will fire, however.

My god, what have I NOT tried would be an easier question. I’ve tried waiting after the player dies, using characteradded, using characteradded and checking if the player was there afterwards. nothing has worked.

Please help!

1 Like

is this being done through a client script or server script?

can you show the code?

2 Likes

It’s in a local script.

Showing the script is a little pointless because none of it is related to the player respawning, but I’ll show where I want it to detect the player respawning.

if map.Name == "ClassicalDimension" then
	task.wait(2)
	write("Oh dear.. It appears you've teleported right into a swordfighting match..")
	write("The only way to leave is to best yourself against your opponent!")
	write("Also, don't worry about death. We've imbedded an immortality chip into your brain.")
	write("Good luck!!!")
	task.wait(0.25)
	summon:FireServer()
	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
	game.Players.LocalPlayer.Character.Humanoid.JumpHeight = 7
	workspace:WaitForChild("ClassicalDimension", math.huge).ClassicalDMusic:Play()
	--if the player dies then respawn with walkspeed and sword
end

2 Likes

It could be that ClassicalDimension is never loaded into workspace and everything under it will not run.

2 Likes

Actually, everything works. the “write” function, setting the walkspeed, everything. It’s detecting the player respawning that won’t work.

However, I have gotten another idea to detect when the player dies, then fire a remote event to load the character.

2 Likes

Put a print after this line and tell me if it runs.

1 Like

that remote event did NOT work btw lolol

1 Like

It worked.


1 Like

Looks like you’re past this… Basic way to get the character on spawn/login.

-- ServerScript
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
       local humanoid = character:WaitForChild("Humanoid") --load pause
       print(character)
    end)
end)

--ClientScript
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid") --load pause
print(character)

The player isn’t going to respawn … the character will.
CharacterAdded:Wait() will fire right when added … not if it’s already there. So you use:
local character = player.Character or player.CharacterAdded:Wait()

1 Like

How would I implement my system to change their walkspeed and give them a sword with this setup?

also I meant “character” when I said that lol

Once you’re at humanoid, that should be easy enough. As for sure now, everything is in place.
May also want to toss in:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local backpack = player:WaitForChild("Backpack")

print(character)
print(backpack)

Access to all you would need.

Do the same thing to locate and lock onto your items, for sure … then clone them over.

top down server script.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		local backpack = player:WaitForChild("Backpack")
        local sword = game.ServerStorage:WaitForChild("Sword")

		humanoid.WalkSpeed = 25
		humanoid.JumpPower = 50

		local clone = sword:Clone()
		clone.Parent = backpack
	end)
end)

Everytime the player respawns this will run again.

1 Like

Unfortunately this didn’t work. Nothing in the output, didn’t even give me the sword…

local sword = game.ServerStorage:WaitForChild(“Sword”)
Is this where your sword is?

The script posted will not fail. It’s even using pauses to make sure.

Yes, my sword is in ServerStorage.

Well, this thread in my script doesn’t happen as soon as you start the game. There’s a LOT of things that happen before it. Plus it’s in an if statement so I feel like theres more to it than just accessing them

It’s something else …
Is it a server script? is everything spelled right? Placement is key also… This need to not have any pasues leading up to it. Should be one of the 1st things done in the script. Getting the character.

If this is something used off a remote you would get the player.character from that.

No, it’s a local script. And I got nothing in the output so definitely nothing is spelled wrong.

Like I said this script it’s in is like the mainframe of my game. There’s like 10 remote events connected to it

This would be a local script …

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local backpack = player:WaitForChild("Backpack")
local sword = game.ReplicatedStorage:WaitForChild("Sword")
-- Need to use ReplicatedStorage for local scripts.

humanoid.WalkSpeed = 25
humanoid.JumpPower = 50

local clone = sword:Clone()
clone.Parent = backpack

Okay, so the swords DO go into my backpack now, but not only is there 8 of them, none of them work. and even if they did work, this wouldn’t solve my main issue. I need these lines to run only when the player respawns after dying. Currently they run after it tells the background music to play.