BodyVelocity help

Hello,
I have a problem with this:

I trying to make shootable item when player press a key.
And that item is stucking in air.

Sorry for bad english :smiley:

Here is the shoot script part:

local function Shoot_Item()
    local Grab_Part = Player.Character:FindFirstChild("HumanoidRootPart").Grab_Part
	local Item = game.Workspace:FindFirstChild(Player.Name .. "_Item")
    Item:Destroy()
    wait(.05)
    local Model = game.Workspace.Players_Items_Placeholder:FindFirstChild(Player.Name .. "_Item")
    Model.Parent = game.Workspace
    Model:SetPrimaryPartCFrame(CFrame.new(Grab_Part.Position))
    Model:SetPrimaryPartCFrame(CFrame.new(Grab_Part.Position, Mouse.Hit.p))
    local BodyVelocity = Instance.new("BodyVelocity",Model.PrimaryPart)
    BodyVelocity.velocity = Model.PrimaryPart.CFrame.lookVector * 90
    BodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
    Model.PrimaryPart.Anchored = false
    Model.Name = "GItem"
end

Did you make sure that all parts in the model are not anchored?

I doubt it is anchored. Possibly the physics replication are freezing midair. The object was moving as if no other parts were anchored.

All parts are not anchored and all parts are have a weld to each other when is in air

The best solution I could think of should be setting the network ownership of the box to the player who fired it. This assures the replication of physics for the player.

Otherwise you can try checking for other alternative methods for launching projectiles.


Closely related: Projectile lagging in server?

Its in local script i must set :SetNetworkOwner() then?

Wait, I thought you were launching the object through server. Otherwise other players cannot see it.

What if i use something like this:
function computeDirection(vec)

local lenSquared = vec.magnitude * vec.magnitude

local invSqrt = 1 / math.sqrt(lenSquared)

return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)

end

Yes i know its singleplayer game

Oh okey i tried to make something like this:

r = game:service("RunService")

Item = script.Parent

Position = Item.Position

function fly()

local Direction = Item.CFrame.lookVector

Position = Position + Direction

local errorr = Position - Item.Position

Item.Velocity = 7*errorr

end

t, s = r.Stepped:wait()

swoosh = script.Parent.Swoosh

swoosh:play()

d = t + 10.0 - s

--connection = Item.Touched:connect(blow)

while t < d do

fly()

t = r.Stepped:wait()

end

And its still not work how i want to

Try changing the network owner to the player who fired it or to the server.

You can learn about this here.