I can't correctly replicate the position of UIObjects

How I see my partner

This is how my partner sees me

Issuer script:

function ReplicatePosition()
	local mapCenter = Map.AbsolutePosition-guiRootAbs

	local viewCenter = (ViewSize / 2)

	local diffX = viewCenter.X - mapCenter.X
	local diffY = viewCenter.Y - mapCenter.Y

	local scaleX = diffX / Map.AbsoluteSize.X
	local scaleY = diffY / Map.AbsoluteSize.Y
	print(scaleX,scaleY)
	PlayerEvents.MovementReplicator:FireServer(Vector2.new(scaleX, scaleY))
end

Receiver Script

PlayerEvents:WaitForChild("MovementReplicator").OnClientEvent:Connect(function(plr: Player, Position2d: Vector2)
	if plr == script.Parent.PLAYER.Value then
		print(Position2d)
		clone.Position = UDim2.fromScale(Position2d.X, Position2d.Y)
	end
end)

Hi. I’m developing a 2D game, but I’m having a problem with replication.

As a player, I calculate the point where the map is located based on the center of the ScreenGuiSize (divide by 2 to get the center).

Then, once I get the center, I give my position to the other players so they can replicate it (scaled so the resolution doesn’t matter (or so I think)). There are always offsets depending on the player’s screen dimensions.

Hierarchy:
“OtherPlayers” is the folder where clones that replicate the position of other players will be added.

Any advice? I’ve even spoken to two different AI’s, and I’ve been searching the forum for days, and I don’t see anyone having the same problem.

I fixed it. It turns out that ScreenGui’s AbsolutePosition and AbsoluteSize don’t trigger :GetPropertyChangedSignal().

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