How can I make this part go flying up and in the direction the player is looking using LookVector or something else?

Hi DevForum! So I want to make it so when you touch a part, it gets sent flying in the direction you’re looking, but I also want it to go up into the air as well.

I know it has something to do with lookvector, but i just cant make it go into the air as it also goes in the direction the player is looking.

I tried a lot, but this is the best I’ve come up with, and would like some assistance:

script.Parent.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		script.Parent.Velocity = hit.Parent.HumanoidRootPart.CFrame.LookVector * Vector3.new(0,100,0)
	end
end)
1 Like

I’d recommend using BodyVelocity to send a part to a specific direction you’re looking.

script.Parent.Touched:Connect(function(hit)
    local model = hit:FindFirstAncestorOfClass('Model')
    if model then
        local humrp = model.HumanoidRootPart

        local wee = Instance.new('BodyVelocity')
        wee.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
        wee.P = math.huge
        wee.Velocity = (humrp.CFrame.LookVector + humrp.CFrame.UpVector) * 40   
        wee.Parent = script.Parent
    end 
end)
3 Likes

Your look Vector looks right. What does it do?

believe this throws a large object, like a basketball, accounting for the Place’s gravity and mass of object but I forget…

mod it

1 Like

Do you want it to have a singular knockback (you touch it, it flings and then it falls down) or a constant knockback (it keeps flying in the specified direction)?

1 Like

Thank you all for your replies @BJCarpenter @Redanite @DEVLocalPlayer ,

So I’m trying to make an American Football so when you touch it, its kind of like a kickoff, where it goes flying off and falls eventually. The script I made doesn’t really send it upward, just flying in the LookVector direction.

I appreciate the script and models you provided, and I did test it but still an issue with it working.

I fixed my code try it now, it should at least fly. Also, make sure your football isn’t anchored as BodyVelocity doesn’t work on an anchored part.

Add a Debris at the end for the falling effect on the BodyVelocity.

Thank you for the help, I appreciate it, and will do. I also forgot to parent the bodyvelocity, which was a silly mistake. Thanks once again, and to everyone else who replied!

This is the code for the old Football ledgens, Open source.

Somewhere in this mass of code is added:
A real football build, which rolls around just like a football; kickoff, punt; pass; fake; lateral; play selection; AI Line Backers, AI pass reciever (Tight End), and a bunch of other stuff for FL II, which was never made…
(The Pass is the worst bit. I wouldn’t use the BodyMover, which it uses…)

https://www.roblox.com/games/151852987/Hike-Ball

GL

Appreciate the reply, thank you for the help!