Trying to use projectile physics to apply a force to a ball for a soccer game. Following a yt tutorial where the code works flawlessly, but mine doesn’t. For some reason, when I create a part and apply the force to the part, it moves, but the ball doesn’t. Here’s my code:
Remotes.ShootBall.OnServerEvent:Connect(function(player: Player, force: Vector3)
local ball: Part = GameValues.Objects.Ball.Value
Events.LosePossession:Fire(player)
Events.UnfreezePlayer:Fire(player)
ball:SetNetworkOwner(nil)
ball.AssemblyLinearVelocity = force
--The code below works for some reason??--
--[[local part = Instance.new("Part")
part.Shape = "Ball"
part.Size = Vector3.new(2,2,2)
part.CanCollide = false
part.Position = ball.Position
part.Parent = workspace
part.AssemblyLinearVelocity = force--]]
end)
The force calculation:
local direction = (shotAim.Position - ballPosition.Position)
local duration = 1
local force = direction/duration + Vector3.new(0, workspace.Gravity * duration * 0.5, 0)