Why isn't this script flinging the humanoid?
01 | local Tool = script.Parent; |
02 | local Handle = Tool:WaitForChild( "Handle" ); |
04 | local PlayerName = Tool.Parent.Parent.Name |
05 | local Player = game.Players:FindFirstChild(PlayerName) |
06 | local BodyPosition = Instance.new( "BodyPosition" ) |
08 | Tool.Activated:Connect( function () |
11 | (Handle.CFrame.lookVector * - 1 ).unit * 5 |
13 | local part, position = workspace:FindPartOnRay(ray, Player.Character, false , true ) |
14 | if Activated = = true then |
16 | print ( "The pan has been pulled out" ) |
18 | if part and not Player then |
19 | print ( "We have found something" , part) |
20 | local hit = part.Parent:FindFirstChild( "UpperTorso" ) |
21 | local Velocity = hit.CFrame.lookVector * - 1 |
23 | print ( "A humanoid hit the pan" ) |
24 | BodyPosition.Position = Velocity + Vector 3. new( 0 , 100 , 0 ) |
25 | BodyPosition.MaxForce = Vector 3. new( 0 , 0 , 1000 ) |
26 | BodyPosition.Parent = hit |
27 | hit.Velocity = (Velocity*- 100 ) + Vector 3. new( 0 , 100 , 0 ) |
28 | print ( "Done fixing velocity" ) |
29 | BodyPosition:Destroy() |
30 | elseif hit = = nil then |
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!