Alternative Constraints: If AlignPosition causes these issues, you might want to try using other constraints like BodyPosition or VectorForce. These can sometimes offer more stable behavior depending on your use case.
Smoothing and Rigidity: Adjusting the smoothing and rigidity properties can help reduce delays and jitter. You can tweak these properties in the AlignPosition constraint to see if it improves performance:
alignPosition.RigidityEnabled = true
alignPosition.Responsiveness = 200 -- Adjust this value as needed
Tried enabling RigidityEnabled but didn’t helped, i’ll try making it with VectorForce of BodyPosition and tell you if this helped (And yes everything is handled on the server)
I found out that BodyPosition is deprecated, and I don’t understand how to use VectorForce in this case, as far as I know, it moves an object in a certain direction, not towards a specific object.
You’re right that BodyPosition is deprecated, my bad. However, you can still achieve the desired effect using VectorForce in combination with other constraints or scripting techniques. Here’s my vision how you can approach it:
Using VectorForce with AlignPosition
AlignPosition for Targeting: Use AlignPosition to set the target position. This will help you define where you want the part to move.
VectorForce for Movement: Use VectorForce to apply the necessary force to move the part towards the target position.
Example
Here’s an example of how you can combine these two:
local part = script.Parent -- The part you want to move
local target = workspace.Target -- The target position (another part or position)
local alignPosition = Instance.new("AlignPosition")
alignPosition.Parent = part
alignPosition.Attachment0 = part:FindFirstChild("Attachment0") or Instance.new("Attachment", part)
alignPosition.Attachment1 = target:FindFirstChild("Attachment1") or Instance.new("Attachment", target)
alignPosition.RigidityEnabled = true
alignPosition.Responsiveness = 200 -- Adjust as needed
local vectorForce = Instance.new("VectorForce")
vectorForce.Parent = part
vectorForce.Attachment0 = part:FindFirstChild("Attachment0")
vectorForce.Force = Vector3.new(0, 0, 0) -- Initial force
local function updateForce()
local direction = (target.Position - part.Position).unit
local distance = (target.Position - part.Position).magnitude
local forceMagnitude = distance * 100 -- Adjust the multiplier as needed
vectorForce.Force = direction * forceMagnitude
end
game:GetService("RunService").Stepped:Connect(function()
updateForce()
end)
Oh here’s some extra things you can do!
Responsiveness: Tweak the Responsiveness property of AlignPosition to control how quickly the part moves towards the target.
Force Multiplier: Adjust the multiplier in the updateForce function to control the strength of the force applied.
I understand, but it seems there will be no such result as with AlignPosition, is there really no way to fix this? I forgot to note that the movement occurs stably on the server, but not on the client.
The SetNetworkOwner attempt is the right thing to do here. When the client had ownership, the part should have actually been moving on the server. The reason it teleported back when the network owner was set back to the server is because the AlignPosition did not have the updated position from the client set. So before you change who owns the part, set the AlignPosition’s target position to the position where the client dropped the part on the server. This would stop the part teleporting back while keeping the part’s movement smooth on the client carrying the part.
It is unfortunate that my work is referred to as the work of artificial intelligence. Unlike artificial intelligence, my code functions as intended. Additionally, you can verify my responses on more challenging subjects, as I have this particular approach to problem-solving. I am a perfectionist with regard to code writing.
I would just say like help yourself in scripting first, I have also noticed that in other topics that you suggest deprecated methods/events to people (that what AI currently does)
Yes, the object moves on the server, but returns back when it is dropped. Are there any examples of how I can set it to the position it was in before the object dropped?
I have been working with Roblox Lua for a considerable amount of time and I do not utilize methods that I am not familiar with. Most often, my work involves manipulation of data, therefore I do not have a deep understanding of newer or obsolete physics-related techniques. Still that’s ok, i can understand.
If you could show us a small portion of the code that is responsible for moving the object in question, we would be able to provide assistance. Additionally, have you attempted to test the game on Roblox servers rather than the development environment?
The client who is responsible for moving the part with the AlignPosition will detect when the client drops the part and can send that to the server. Then, the server will either disable the align position (so the part just drops) or update the align position to the position sent from the client. Then, you set the network owner back to the server. Also, if you disable the AlignPosition, then make sure to turn it back on when clients start moving the parts (do this clientside and you would not even have to disable AlignPosition on the server in the first place).
Other players will always have network ownership over their own character models, so unfortunately, I don’t think so. What you could do though is clone the ragdoll on the server and make the real one invisible. Then, use another AlignPosition to align both ragdolls to each other, and give the cloned ragdoll’s networkownership to the client moving it. You would also have to set the cancollide of these models off which you could do with collision groups and PhysicsService (humanoids set cancollide back to true automatically so using cancollide alone may not work).