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)
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)
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)?
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.
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…)