I want to create a football ball using linear velocity where when the player’s hitbox touches the ball it will go in that direction smoothly (I tried to use force and it makes the ball direction really buggy). I used the code below and the direction isn’t buggy anymore but the ball is now extremely laggy. Any solutions to make the ball better? Or a better way to code movement balls?
local ball = script.Parent
wait(1)
ball:SetNetworkOwner(nil)
local Debris = game:GetService("Debris")
function onTouched(otherPart)
if otherPart.Name == "HitBox" then
local hitbox = otherPart
local Char = otherPart.Parent
local mode = Char.Mode.Value
local punch = script.Parent.Punch.Value * 2
local HRP = Char.HumanoidRootPart
if mode == 1 then
local Attachment = Instance.new("Attachment")
local LV = Instance.new("LinearVelocity")
LV.MaxForce = 1e9
LV.VectorVelocity = HRP.CFrame.lookVector * punch
LV.Attachment0 = Attachment
Attachment.Parent = script.Parent
LV.Parent = script.Parent
Debris:AddItem(LV, 1)
Debris:AddItem(Attachment, 1)