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
CZXPEK
(czo)
April 23, 2023, 7:36pm
#2
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
CZXPEK
(czo)
April 23, 2023, 7:37pm
#5
Both LocalScripts and ServerScripts work in StarterCharacterScripts
quakage
(quakage)
April 23, 2023, 7:38pm
#6
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
oh sorry wait a sec i will fix it
I just fixed it, it must work.(my fisrt message here)
system
(system)
Closed
May 7, 2023, 7:45pm
#10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.