CharacterAdded not firing?

Hello there,

I’m trying to enable a UI when a player dies and they spawn but CharacterAdded seems to not be firing. Here is my code:

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Humanoid = Character:WaitForChild("Humanoid")

local PlayerGui = Player:WaitForChild("PlayerGui")

local Sprinting = false

local Mouse = Player:GetMouse()

local Camera = workspace.CurrentCamera



	warn("Character respawned")


“CharacterRespawned” never prints in the output.

Any help is appreciated, thanks.

1 Like

where is the script located at?

The script is located in PlayerGui

try putting it in starterplayerscripts

Is there any other way other that moving the script? The script handles almost all the UI in the game so moving it would result in some code breaking.

So, since you’re using the script under the StarterGui it will not fire the CharacterAdded script only after you die once more (As long as you have ResetOnSpawn property set to false). Therefore to get this to work the first time like Overseerzed suggested is to place it into the StarterPlayerScripts.

Not necessarily, you can move the script to PlayerScripts without anything breaking. I actually script all my UI in the StarterPlayerScripts. It may require some recoding but it’s good practice and very much worth it since you’re introduced to more features.

Really? I always considered everything to do with UI to end up in PlayerGui. My GameClient script which handles a lot of the games features is in StarterPlayerScripts since it wouldn’t make much sense for it to be in PlayerGui.

What new features come with placing the script in StarterPlayerScripts?

Not exactly new features but as more features to work with. You can essentially do more than you can if you were just scripting inside the StarterGui. I also don’t script inside the StarterGui for the sake of organization… I don’t like having to go into each UI to access it’s scripts. Yes, it’ll take a little more work if you were to script inside the StarterPlayerScripts and it is not a very major difference when it comes to the two services however just like how CharacterAdded doesn’t fire many other features that you could use in StarterPlayerScripts scripting UI will work unlike the StarterGui.

The only exception that I have when I come to scripting inside the StarterGui is if I need to create a single controller for that specific UI to handle just the UI things - If it has to expand outside the StarterGui and I work so much outside than inside the StarterGui then I consider coding inside the StarterPlayerScripts instead.

All the UI in the game is handled by 1 script which is in StarterGui with the help of a few UI modules. Although I think I will move it to StarterPlayerScripts.

I reset my Character twice yet it still doesn’t fire

ResetOnSpawn is set to false? Otherwise it shouldn’t work, if that still doesn’t work lmk

At the moment all I’m trying to do to see if it registers is print “Character Respawned from death” but it doesn’t print.

Yeah did you disable ResetOnSpawn though?

If you mean for the UI then yes ResetOnSpawn is false.

Instead if you don’t want to swap to the StarterPlayerScripts you may need to check if the character is being added in the StarterPlayerScripts then fire a bindableevent and tell the UI scripts that the character has been loaded

Just tried the same few lines of code in a script in StarterPlayerScripts and it works, gonna have to do some tweaking to the main UI code but apart from that its all good.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.