Idk why it won't work, but the title is the error I get on Line 17.
This is a ServerSide Script inside a Tool, and I'm trying to help other people on my game since it deals with stealing a basketball.. and the magnitude should help them so that whenever a person is close, they'll steal the ball.
local tool=script.Parent tool.Handle.Touched:connect(function(hit) local char=hit.Parent if char:IsA("Accessory") then wait() elseif char:FindFirstChild("Humanoid") and char:FindFirstChild("Torso") and tool.Parent:FindFirstChild("Torso") then script.Disabled=true if (tool.Parent.Torso.Position-tool.Handle.Position).magnitude>5 and char.Humanoid.PlatformStand==false then -- magnitude char.Humanoid.PlatformStand=true local s=script.Stand:Clone() s.Parent=char.Humanoid s.Disabled=false else tool.Parent=workspace wait() tool.Parent=char wait(1) end else if (tool.Parent.Torso.Position-char.Torso.Position).magnitude<=5.5 then -- magnitude tool.Parent=workspace wait() tool.Parent=char wait(1) end end wait(1) script.Disabled=false end)
Thanks,
LukeGabrieI aka EnergyBrickz
From what I understand is that this tool is the ball. The script is supposed to give the ball to another player if they hit the ball at a distance of fewer than 5 studs. I don't understand the reason for the PlatformStand.
Your error is because the script can't find Torso.
local tool = script.Parent local handle = tool:WaitForChild("Handle") print("Loaded") handle.Touched:connect(function(hit) if hit.Parent ~= nil then -- if what you hit still exists local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and player.Character then local char = player.Character local torso = char:findFirstChild("Torso") local hum = char:findFirstChild("Humanoid") if torso and hum and hum.Health > 0 then -- make sure they aren't dead local dist = (torso.Position - handle.Position).magnitude if dist < 5 then tool.Parent = char end end end end end)