Attempt to index nil with humanoid?

I am trying to figure out why this script wont work and do whats it is soposed to do which is delete something on death/ disable scripts

p.s this is a local script inside starterplayerscripts

function onDeath()
	game.Workspace.Areatest2:Destroy()
	script.Parent.Outsideload.Enabled = false
	game.Workspace.Areatest1:Destroy()
	script.Parent.Insideload.Enabled = false
	print("Deleted Map")
end

game.Players.LocalPlayer.Character.Humanoid.Died:Connect(onDeath)

I need help with this

Place the script in StarterPlayer → StarterCharacterScripts or just add a task.wait(2) at the top

Put this on end of your script and delete last line

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
char:WaitForChild("Humanoid").Died:Connect(onDeath)

it needs to be client sided so other players are not affected

Both LocalScripts and ServerScripts work in StarterCharacterScripts

Have you tried putting it in the StarterCharacterScripts? You are expecting to use the Character field which probably isn’t set up yet when StartPlayerScripts runs.

for some reason this happens
image

oh sorry wait a sec i will fix it

I just fixed it, it must work.(my fisrt message here)

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