Im making a Alien that when he dies he self destructs but not kill you but the block from the lighting won't teleport to workspace where the torso is here is the script.
TorsoPos = script.Parent.Torso ExplosionDamageBlock = game.Lighting.ExplosionDamage while wait(1) do if script.Parent.Alien.Health < 1 then ExplosionDamageBlock:clone().Parent = workspace ExplosionDamageBlock.Position = TorsoPos.Position Explosion = Instance.new("Explosion") Explosion.BlastPressure = 10 Explosion.BlastRadius = 0 Explosion.DestroyJointRadiusPercent = 0 Explosion.Position = TorsoPos.Position Explosion.Parent = script.Parent.Torso wait(5) script.Parent:remove() end end
The error I found in this code:
TorsoPos = script.Parent.Torso ExplosionDamageBlock = game.Lighting.ExplosionDamage while wait(1) do if script.Parent.Alien.Health < 1 then ExplosionDamageBlock:clone().Parent = workspace -- All right, you've set that to workspace. ExplosionDamageBlock.Position = TorsoPos.Position -- Not all right, since you're referring back to the ExplosionDamageBlock variable (game.Lighting.ExplosionDamage), not its clone.
Perhaps use a local variable to distinguish which variable goes with which object:
ExpDmgBlck = ExplosionDamageBlock:clone() ExpDmgBlck.Parent = workspace ExpDmgBlck.Position = TorsoPos.Position
SIDE NOTE
What your script is doing while it is running is checking the Alien's health every second. This might affect and raise the amount of activity (lag) in a server. One of the solutions is to make the function fire when the humanoid is altered by using
Changed()
orDied()
events:script.Parent.Alien.Changed:connect(function (Health) if script.Parent.Alien.Health < 1 then --[[ Your function ]] end end)script.Parent.Alien.Died:connect(function () --[[ Your function, without the 'if' statement ]] end)
You forgot to capitalize "Clone()" and "Remove()"
TorsoPos = script.Parent.Torso ExplosionDamageBlock = game.Lighting.ExplosionDamage while wait(1) do if script.Parent.Alien.Health < 1 then ExplosionDamageBlock:Clone().Parent = workspace ExplosionDamageBlock.Position = TorsoPos.Position Explosion = Instance.new("Explosion") Explosion.BlastPressure = 10 Explosion.BlastRadius = 0 Explosion.DestroyJointRadiusPercent = 0 Explosion.Position = TorsoPos.Position Explosion.Parent = script.Parent.Torso wait(5) script.Parent:Remove() end end
You didn't capitalize Clone, and I wouldn't recommend you use remove.
TorsoPos = script.Parent.Torso ExplosionDamageBlock = game.Lighting.ExplosionDamage while wait(1) do if script.Parent.Alien.Humanoid.Health <= 0 then --I also see another problem, health is located inside the humanoid, not the object itself. ExplosionDamageBlock:Clone().Parent = game.Workspace ExplosionDamageBlock.Position = TorsoPos.Position Explosion = Instance.new("Explosion") Explosion.BlastPressure = 10 Explosion.BlastRadius = 0 Explosion.DestroyJointRadiusPercent = 0 Explosion.Position = TorsoPos.Position Explosion.Parent = script.Parent.Torso wait(5) script.Parent:Destroy() --Changed to Destroy end end