I am making a character customizer and for some reason, the updates to the position of the hat are not being replicated to all clients. They appear on the server-side, but not on the other clients other than yours.
I am extremely confused as to why this is happening, why?
The movement of the hat is controlled by handles (on your client), then when you release it replicates to the server, but for some reason, the other clients are not receiving this change.
(HANDLES - CLIENT)
handles.MouseButton1Down:Connect(function(face: Enum.NormalId)
adornee = handles.Adornee
initialPartCFrame = adornee.CFrame -- save the part's CFrame
end)
handles.MouseDrag:Connect(function(face: Enum.NormalId, distance: number)
adornee = handles.Adornee
-- Calculate new position with local axis
local localMovement = CFrame.new(Vector3.fromNormalId(face) * distance)
local targetCFrame = initialPartCFrame * localMovement
adornee.Position = targetCFrame.Position
end)
(UPDATE TO SERVER - CLIENT)
(not full code)
-- create handles for it
local newHandle = moveHandles:Clone()
newHandle.Parent = handlesFolder
newHandle.Adornee = accessoryLink.Value.Handle
newHandle.MouseButton1Up:Connect(function()
updateAssetEvent:FireServer(newHandle.Adornee, {
["Position"] = newHandle.Adornee.Position
})
end)
(SERVER RECEIVING UPDATE - SERVER)
local function updateAsset(player, asset, details)
local position = details["Position"]
if position then
asset.Position = position
end
end
UpdateAssetEvent.OnServerEvent:Connect(updateAsset)
As best as I can put it, the change is working on your client and on the server, but NOT for other clients.
So yes, it works only on the client with the modification, but it also works on the server, its just other clients arent receiving the change, even though the change is appearing on the server-side.
Is the change already applied on your client? Is it possible that it’s not replicating for any client?
What type of connection is between the hat and the character? I assume you’re using .Position to modify a WeldConstraint specifically? I believe that should replicate (unless there are multiple constraints controlling it, though a character should be set up properly).
The change is being applied whenever the handles are released, its being applied the client using it. It is also being applied to the server, just not any other client than your own.
I am just modifying the position of the Handle as this is an accessory, technically it is attached to a weld.
Also, I have found a fix for this by doing the same thing on the server (updating the position) and using :FireAllClients(), but I really want to know why the server-side changes are not replicating to the client.
Can the player move the accessories’ position? If you’re just trying to make it appear on the player, i’d recommend directly having a version of the accessory who would be cloned and become child of the player character when chosen.
Another method could also just be having a hat with a mesh with no ID or set to transparent, and change the Transparency and/or meshID to whatever is being selected.
I’m not sure but if the position value is stored somewhere originally on the client, that might be whats causing it.
I cannot really help much more due to being busy so if it’s not that, i hope you find a solution.
But make sure you do troubleshoot this as the issue may be minor.
Make sure the client is correctly firing the event to the server
Make sure all the variables and instances are properly orthographed
Make sure the position is not stored in a way that prevents it from being changed by the server
I appreciate the help, but I have stated quite a few times now that the changes are being replicated to the server, and I don’t know what orthographed means.
For anyone in the future trying to do something similar, I was able to fix it by having the server send a :FireAllClients() to the client-side to do the same thing, and that appears to work. Though this was not a fix I wanted.