How can I set up my game so that each player sees the same thing?

I’m designing a tile battle game based on the old flash game “jelly battle”, if anyone is familiar with that. I’ve got it set up so that numerous tiles move down a grid in intervals, and in the interval between the tile moving each player can select a tile that he or she wants to jump to next. This all works well and dandy for the individual player, however whenever I run my game in server mode for two players, each one sees the other player as being stuck where they spawned.

Inside of a local script which I insert in each player when they spawn, I create a part labeled “cPart”, which had more purpose in the beginning of the design for this game but may be a bit redundant now. As of right now its’ only purpose is to give a location marker for the character which the part of my code dealing with the character’s jumps can use to calculate the direction of the jump.

This cPart is then welded to the characters HumanoidRootPart, and then the primary part of the character is set to the “PlayerStart” position, which is the position assigned to each player for where they start on the tile grid.

local cPart ="Part")
cPart.Name = "cPart"	
cPart.Transparency = 1
cPart.CanCollide = false
cPart.Anchored = true
cPart.Parent = char

local function weldBetween(a,b)
	local weld ="ManualWeld", a)
	weld.Part0 = a
	weld.Part1 = b
	weld.C0 = a.CFrame:inverse() * b.CFrame
	return weld

cPart.Position = char.HumanoidRootPart.Position -, 4, 0)

local weld = weldBetween(char.HumanoidRootPart, cPart)


char:SetPrimaryPartCFrame("PlayerStart"..playerInt.Value).Position +,3.5,0)))

The purpose for handling this bit of information on the client is for the smoothness of animation that comes from the “jump” part of my code.

After this I have a bit of code for replication which I borrowed from the developer forum, which is supposed to use a remote event to replicate the position of the character to the server.

local Replication = replicatedStorage.Replication

    game.Workspace:FindFirstChild(Player.Name).HumanoidRootPart.Position = Position


And I of course have the complimentary code to this server side.

local Replication = replicatedStorage.Replication

    for _,Player in pairs (game.Players:GetPlayers()) do
        if Player ~= Sender then

What can I try to make either the replication code work or to just make sure players are seeing each other where they’re supposed to be? I’ve tried a bunch of fanegling of the code and have had no results, I wish I could say in more detail what I did but I am honestly just coming back to this project for the first time in months because of how much frustration this particular issue caused. There’s a lot more to the game then I’ve shared and if any additional info might be helpful let me know and I’ll include it. Literally any ideas to help me get the ball rolling, or reading material for me to become better educated, would be much appreciated.

Thanks :smile:

1 Like