hey guys i just picked up scripting today and am attempting to create a dummy that dies when they are clicked and then respawn. Honestly i dont know what im doing but so far i havent been stuck on something for this long. Basically the dummy does respawn once killed but clicking on them again does nothing and they dont die. I then get the error in the title, if you guys could help me i would be very grateful. I did look this up before posting and found that this happens if the script tries to find the humanoid before it exists but the humanoid is always there long before the script tries to find it so idk. Here is my script
local pdummy = game.Workspace["respawning dummy 1"]["Player Dummy"]
local spdummy = game.ServerStorage["Player Dummy"]
local clickdetector = game.Workspace["respawning dummy 1"]["Player Dummy"]["HumanoidRootPart"]["ClickDetector"]
clickdetector.MouseClick:Connect (function()
pdummy.Torso.WeldConstraint.Enabled = false
pdummy.Head.WeldConstraint.Enabled = false
pdummy["Left Leg"].WeldConstraint.Enabled = false
pdummy["Right Leg"].WeldConstraint.Enabled = false
pdummy["Left Arm"].WeldConstraint.Enabled = false
pdummy["Right Arm"].WeldConstraint.Enabled = false
wait(0.1)
local explosion = Instance.new("Explosion",pdummy)
explosion.BlastRadius = 5
explosion.ExplosionType = Enum.ExplosionType.NoCraters
explosion.Position = pdummy.Torso.Position
explosion.BlastPressure = 500000
explosion.DestroyJointRadiusPercent = 0
pdummy.Head.oof.Playing = true
pdummy.Humanoid.Health = 0
wait (2)
end)
while true do
wait(5)
if pdummy.Humanoid.Health == 0 then
pdummy:Destroy()
copy=spdummy:clone()
spdummy.Parent = game.Workspace["respawning dummy 1"]
spdummy = pdummy
end

1 comment
Thanks man this really helped