Vector Velocity doesn't work

Hello developers! For my game, I made a system where you can hold and move different props. For that I used align orientation and vector velocity. But for some reason when I activate script, it doesn’t immediately start working, but rather prop moves to camera out of nowhere without aligning orientation.
Here’s the script:

local model = prop.Model
local playerInfo = LocalServerInfo.GetLocalPlayerInfo()
playerInfo.isHoldingProp=true
	
local attachment = Instance.new("Attachment",model.PrimaryPart)
attachment.CFrame=CFrame.new(0,0,0)
	
local alignOrientation = Instance.new("AlignOrientation",attachment)
alignOrientation.Attachment0=attachment
alignOrientation.Mode=Enum.OrientationAlignmentMode.OneAttachment
alignOrientation.Enabled= true
	
local linearVelocity = Instance.new("LinearVelocity",attachment)
linearVelocity.Attachment0=attachment
linearVelocity.MaxForce=MaxForce
linearVelocity.Enabled=true
	
local connection
local holdcoro
	
holdcoro = coroutine.wrap(function()
	while playerInfo.isHoldingProp do
                print("Started Holding")
		local cameracframe = camera.CFrame
		local desiredPosition = cameracframe*CFrame.new(0,0,-CurrentHoldDistance)
		local rx,ry,rz = cameracframe:ToOrientation()
		alignOrientation.CFrame=CFrame.new() * CFrame.Angles(math.rad(rx),math.rad(ry),math.rad(rz))
		--alignOrientation.CFrame=cameracframe.LookVector
		local lookVector = (desiredPosition.Position - attachment.WorldCFrame.Position).unit
		local distance = (desiredPosition.Position - attachment.WorldCFrame.Position).Magnitude
		
		local speed = (distance/0.1)
		if speed < 0.05 then speed = 0 end
		local velocity = lookVector*(distance/0.1)
                print("Current VectorVelocity Velocity: ",velocity)
		linearVelocity.VectorVelocity=velocity
		--model:SetPrimaryPartCFrame(desiredPosition)
		
		task.wait(0.05)
	end
end)
holdcoro()

Here’s a video of it:

Can I ask what ‘MaxForce’ is? If it is too low of a value, it will not have enough power to lift the object in the first place.

1 Like

Oh, it’s 10000 higher in the script

Try modifying MaxForce to a higher value like 100000 or 1000000 and tell me if anything changes.

Even better: inf.

1 Like

No, it’s the same
here’s video

Did you parent the LinearVelocity and AlignOrientation?

Yeah they’re attachment’s children

I’m not an expert when it comes to physics in Roblox, but try parenting it to the part rather than the direct attachment.

No, it didn’t work. I have a feeling that it somehow connected to client’s performance, but I can’t say for sure

Can you see the LinearVelocity and AlignOrientation instances inside the prop in the explorer in-game? I’m stumped, just trying to narrow down an answer.

Yeah, they’re in workspace on client side

why not use align position rather than vector velocity?

Same thing. I mean it works, just like Velocity, but the problem is that it works only after some time, like it’s shown in the first video. It takes like a minute for the prop to start moving

I found what was the problem. Basically, I created align instances on client and I didn’t set the said client as network owner. So basically I needed to create remote event and using it tell server to set client to network owner like this

remote.OnServerEvent:Connect(function(player,status,prop)
	if status then
		prop.PrimaryPart:SetNetworkOwner(player)
	else
		prop.PrimaryPart:SetNetworkOwner(nil)
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.