I’m trying to make a Part that goes in front of the player using CFrame, the only problem is that i need to make it Server Sided so the other players can see it too, but it makes the CFrame inacurate to the Character’s current CFrame, i’ve already tried calculating the CFrame on the client and then just send it to the Server, it improves a lot but it still doesn’t reach the result that i want.
Standard remotes inherently have some delay due to their behaviour. What you might be looking for are Unreliable Remote Events. These remote events are not guaranteed to arrive to the server/client in order of being sent, but will arrive with shorter delay. If you fire these within a heartbeat (so every frame), this lack of order won’t matter as the next frame will correct any mistakes made from this ‘lack of order’.
Alternatively, you could implement velocity prediction where the server calculates where the part ‘should be’ after the CFrame has been received on the server by combining the player’s latency with the player’s character velocity.
You could try doing the calculations on every client. I’ve done something similar where I added the part to a tagged collection with a couple attributes that defined what player it was supposed to be attached to and the position offset.
i saw a person saying that the Velocity Prediction is not much accurate, since it doesnt get the raw ping, but i think that i’m gonna give the unreliable remote events a try
there is actually a simple solution to this problem.
you can use the character’s cframe from the client, but you have to update it on the server every time it changes.
also, if the difference is noticeable, thats just a bad ping issue. you cant really do much about it except from buying better internet.
Sorry I’m late, but you’re able to use SetNetworkOwner to achieve this.
I put these two scripts super quickly.
They give the first player to join Network Ownership over a part.
You can obviously give other players network ownership but that will require some experimentation.
ServerScript:
local owner; owner = game.Players.PlayerAdded:Connect(function(plr)
local part = workspace:WaitForChild("Part")
local obj = part:FindFirstChild("obj")
if not obj then
obj = Instance.new("ObjectValue")
obj.Parent = part
obj.Name = "obj"
end
obj.Value = plr
part:SetNetworkOwner(plr)
owner:Disconnect()
end)
LocalScript (StarterCharacter):
local part = workspace:WaitForChild("Part")
local obj = part:WaitForChild("obj")
local plr = game.Players.LocalPlayer
local char = script.Parent
local rootpart = char:WaitForChild("HumanoidRootPart")
while task.wait() do
if obj.Value == plr then
part.CFrame = rootpart.CFrame * CFrame.new(0, 0, -5)
part.AssemblyLinearVelocity = Vector3.zero
end
end
i think that i would have to send a RemoteEvent to the server only to change the network ownership of the Part, so i dont think that i’m going to do that. Thank you all for answering my question.