So basically the function of this script is supposed to be this:
Once a certain player in the game dies, a block is destroyed. [In this case myself, PoInareffe] I don't know which part of the script is broken, though I have tried to test each part of the script alone with a 'print' though it shows no real results.
I am also getting an error at the "victim.hum.Health == 0 then" line which is saying "Syntax error: Expected identifier when parsing expression, got 'then'". I am not sure what to make of this except the fact that the 'then' is probably not supposed to be there though I do not know what to replace it with. Any help with fixing this would be appreciated!
local victim = game.Players:FindFirstChild("PoInareffe") local char = victim.Character local hum = char.Humanoid local lay = game.Workspace.PlaceDie.Lay.Part victim.hum.Health == 0 then lay:Destroy() end
I am relatively new to scripting so excuse my messy script.
The char
variable is not really needed, since the victim
is the Character
itself. You also forgot the if
at line 6
or you may have removed it unaware.
local victim = game.Players:FindFirstChild("PoInareffe") local hum = victim.Humanoid -- Removed char variable, changed 'char.Humanoid' to 'victim.Humanoid' local lay = game.Workspace.PlaceDie.Lay.Part -- Added 'if', removed 'victim' if hum.Health == 0 then lay:Destroy() end
Also it will not work since this script will only run once, you are better off using Humanoid.Died
hum.Died:Connect(function() lay:Destroy() end)