local Tool = script.Parent;
local Handle = Tool:WaitForChild("Handle");
local Activated = true
local PlayerName = Tool.Parent.Parent.Name
local Player = game.Players:FindFirstChild(PlayerName)
local BodyPosition = Instance.new("BodyPosition")
Tool.Activated:Connect(function()
local ray = Ray.new(
Handle.CFrame.p,
(Handle.CFrame.lookVector * -1).unit * 5
)
local part, position = workspace:FindPartOnRay(ray, Player.Character, false, true)
if Activated == true then
Activated = false
print("The pan has been pulled out")
print(part)
if part and not Player then
print("We have found something", part)
local hit = part.Parent:FindFirstChild("UpperTorso")
local Velocity = hit.CFrame.lookVector * -1
if hit then
print("A humanoid hit the pan")
BodyPosition.Position = Velocity + Vector3.new(0, 100, 0)
BodyPosition.MaxForce = Vector3.new(0,0,1000)
BodyPosition.Parent = hit
hit.Velocity = (Velocity*-100) + Vector3.new(0,100,0)
print("Done fixing velocity")
BodyPosition:Destroy()
elseif hit == nil then
return end
end
Activated = true
end
end)
The script is supposed to basically fling the humanoid it touches backward a little bit, but at the moment it does not do that and I do not know why. There are no errors in the script. Any help would be appreciated!
