Humanoid Health isn't accessible with server scripts

I have a script that prints a specific statement when the player dies the script it in StarterCharacterScripts and doesn’t work unless there’s a localscript doing the same function which is really rigged.
I used health changed, I tried checking if the players health is 0 or under but nothing seems to work. How do I fix this? any help is appreciated, Ive already tried using the wait and runservice loop to check if health is under 0 and it doesn’t work, so thats checked off.

1 Like

If you wanted to check if a player dies, just use the Humanoid.Died event, or is that not possible either?

Do you have any code so far that we can see what’s going on?

2 Likes

Thats the first thing I tried so I didn’t bother mentioning it and heres the code. image

Are you getting any errors? The only thing I see that could be the problem is that the Humanoid may’ve not existed by the time the event was set up, maybe try this?

local diedalready = false

local char = script.Parent
local hum = char:WaitForChild("Humanoid")

hum.Died:Connect(function()
	diedalready = true
	print("HEALTH CHANGEDDD")
end)
1 Like

No errors, I would’ve said it if there were any I just cant access the humanoid somehow.

I’ll be checking if other background scripts are affecting it

1 Like

There are no scripts affected it.

If it’s in a localscript you want to use game.Players.LocalPlayer rather than script.Parent, and the reason it only works in a LocalScript is because it’s in StarterCharacterScripts

1 Like

Its a server script i said it in the title.

Convert it to a localscript if you’re going to have it in StarterCharacterScripts

1 Like

so i cant have any server scri[pt in StarterCharacterScripts?

No, as it’s part of the client. If you wanted to do the same on the server you could use a server script

1 Like

The problem is I want to print in the server and not by client, client works perfectly fine and remote events work fine too the problem is if the player has a exceedingly high ping it could affect what im trying to accomplish

You can have a server script in StarterCharacterScripts, you can’t have a server script in StarterPlayerScripts

1 Like

Not in Startergui too? Because i tried and it still didnt work.

Didn’t know that, I stand corrected

1 Like

You can, but it’s not recommended because the client should be handling the UI.


Are you using the client or the server to kill the player?

1 Like

Each of my weapons use remote events to damage players so its server.

Also im wondering does the command bar in studio client or server?

Nevermind. I realized the health was being changed by a localscript.