I’m making it so that you can pick up objects and throw them around. The picking part is working fine but the throwing part is glitchy and sometimes the object freezes mid air. Here’s the code related to the throwing object part:
local function FlingObject()
if hitbox then
local mouseHit = playerMouse.Hit
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local object = hitbox.Parent
local objectWeld = hitbox:FindFirstChild("ObjectWeld")
local bodyForce = Instance.new("BodyForce")
bodyForce.Force = (mouseHit.Position).Unit * velocityAmplifier
bodyForce.Parent = hitbox
if objectWeld then
print("Destroying weld")
objectWeld:Destroy()
end
object.CanCollide = true
hitbox = nil
Debris:AddItem(bodyForce, debrisTime)
end
end
The value of velocityAmplifier is: 2500 and debrisTime: 0.2
Try to set the network owner to the client and check if anything else is anchoring it. For more information, after the object is frozen, is anything inside the model Anchored?
I’m pretty sure your issue is due to the NetworkOwnership of the thrown item transferring from your Client to the Server. When it passes from one to the other it takes a split second, causing lag and glitches in some cases.
I don’t think the BodyForce you are using is the problem, but you could give VectorForce a try.
As @lanjtlike said, if you set the NetworkOwnership of the thrown item to the Client it would look better for you, but others may see it lag.