Please help me, my script was working perfectly fine then one day it just stopped it keeps saying position is nil even tho all my other scripts work perfectly fine
its the “if (player.Character.pullbox.Position - hrp.Position).magnitude < dist then” line that is giving me issues
my script:
local dist = 10
local TweenService = game:GetService("TweenService")
local debris = game:GetService("Debris")
local ishit = false
script.Parent.OnServerEvent:Connect(function(player)
ishit = false
while ishit == false do
wait(0.001)
local pos = player.Character.pullingbox
for i, v in pairs(game.Workspace:GetChildren()) do
local hum = v:FindFirstChild("Humanoid")
local hrp = v:FindFirstChild("HumanoidRootPart")
local torso = v:FindFirstChild("Torso")
if hum and torso and v ~= player.Character then
if (player.Character.pullbox.Position - hrp.Position).magnitude < dist then
print("hit")
hum:TakeDamage(20)
local stun = Instance.new("StringValue")
stun.Parent = hrp
stun.Name = "Stun"
hrp.Anchored = true
debris:AddItem(stun,1.25)
ishit = true
player.Character.pullbox:Destroy()
local goal2 = {}
goal2.CFrame = pos.CFrame
local info2 = TweenInfo.new(0.25,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out)
local tween2 = TweenService:Create(hrp,info2,goal2)
tween2:Play()
wait(0.5)
tween2:Destroy()
pos:Destroy()
wait(0.75)
if not player.Character.HumanoidRootPart:FindFirstChild("1StunM1") and not player.Character.HumanoidRootPart:FindFirstChild("2StunM1") and not player.Character.HumanoidRootPart:FindFirstChild("3StunM1") and not player.Character.HumanoidRootPart:FindFirstChild("4StunM1") and not player.Character.HumanoidRootPart:FindFirstChild("5StunM1") then
hrp.Anchored = false
end
end
end
end
end
end)
please help me if you can.