Maybe try to use that function WHEN the new projectile is in throwing?
Wdym? Should I set the NetworkOwner after I add the body forces and such?
If that’s how you make it throwable, then yes.
Not really sure by what you mean “make it throwable.” Would the code where I duplicate the handle count? I can try putting it after the body forces and see if that fixes it.
Current Code:
local throwingHandle = handle:Clone()
throwingHandle.Parent = workspace
handle.Throw:Play() -- Play the throw sound
throwingHandle.Velocity = (target - throwingHandle.CFrame.p).unit * 100
-- set the orientation to the direction it is being thrown in
throwingHandle.CFrame = CFrame.new(throwingHandle.CFrame.p, throwingHandle.CFrame.p + throwingHandle.Velocity) * CFrame.Angles(0, 0, math.rad(-90))
local floatingForce = Instance.new('BodyForce', throwingHandle)
floatingForce.force = Vector3.new(0, 196.2 * throwingHandle:GetMass() * 0.98, 0)
local spin = Instance.new('BodyAngularVelocity', throwingHandle)
spin.angularvelocity = throwingHandle.CFrame:vectorToWorldSpace(Vector3.new(0, -200, 0))
throwingHandle:SetNetworkOwner(nil)
(Also, sorry if this is frustrating… I’m not that good at scripting.)
EDIT: Tried the :SetNetworkOwner() function and it did nothing. If anything, it seems like the delay is more…
Use SetNetworkOwner(nil). This will set the physics handler for the knife to the server to guarantee a smooth effect. Try using the new physics API BasePart:ApplyImpulse(Vector3) and :ApplyAngularImpulse(Vector3) instead of the regular body force. Also try to avoid using legacy body movers for projectiles unless it’s the BodyForce
. I haven’t tested it, but you can try using or adapting this code to fit your purposes:
local throwingHandle = handle:Clone()
throwingHandle:SetNetworkOwner(nil) -- Have the Server calculate the physics
handle.Throw:Play() -- Play the throw sound
-- Set the orientation to the direction it is being thrown in
throwingHandle.CFrame = CFrame.lookAt(throwingHandle.CFrame.p, throwingHandle.CFrame.Position + throwingHandle.AssemblyLinearVelocity) * CFrame.Angles(0, 0, math.rad(-90))
-- Counteracts the gravity force acting upon the thrown knife
local floatingForce = Instance.new('BodyForce', throwingHandle)
floatingForce.force = Vector3.new(0, 196.2 * throwingHandle:GetMass() * 0.98, 0)
-- Sets the parent of the throwing knife
throwingHandle.Parent = workspace
-- Calculates the throw force's
local throwForce = Vector3.new((target - throwingHandle.CFrame.Position).Unit) * 100
local rotateForce = throwingHandle.CFrame:VectorToWorldSpace(Vector3.new(0, -200, 0))
-- wait(0.03) -- You may want to try using a wait if it doesn't work at first
-- Flings the knife
throwingHandle:ApplyImpulse(throwForce)
throwingHandle:ApplyAngularImpulse(rotateForce)