So everything works fine the first time, the shark follows me and kills me. But the second time it says that the torso on Line 6-7 is nil and the shark just freezes in place :(
local bodypos = Instance.new("BodyPosition", script.Parent)
while true do
wait()
for i, v in pairs(game.Workspace:GetChildren())do
if v:IsA("Model") and v:FindFirstChild("Humanoid") then
local torso = v:FindFirstChild("Torso")
magnitude = (torso.Position - script.Parent.Position).magnitude
if magnitude < 500 then
--script.Parent.Rotation = torso.Rotation
bodypos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodypos.Position = torso.Position
--bodypos.P = 10000
--bodypos.D = 100000
end
end
end
end
Help will be really appreciated :>

2 comments
When a player respawns the torso is nil (for a few ms.). add "if torso then" on line 7
Thanks! That was a simple fix and it worked :)