Seperate clients reporting to the server and the server replicates all the clients to each client

So I have this Height Bar Gui for a tower of hell type game. But it only shows the height of the player that is playing. I want it to show the heights of everyone in the server in real-time.

How do I achieve this?

3 Likes

Make a local script which receives updates from the server or check player height for all characters in workspace

1 Like

Just make a bindableevent

BindableEvent:Fire(height, player)
BindableEvent.Event:Connect(function(height, player)
   --write the code for recording jumps here
end)

or do this:
add a modulescript in repstorage named PlayerHeights
in localscript:

local playerHeights = require(game:GetService("ReplicatedStorage"):WaitForChild("PlayerHeights"))

game:GetService("RunService").RenderStepped:Connect(function()
   for _, plr in pairs(playerHeights) do
      local player = game:GetService("Players"):FindFirstChild(plr[1])
      if player then
         --record height
      end
   end

   for _, v in pairs(playerHeights) do
      if v[1] == game.Players.LocalPlayer.Name then
         v[2] = thisplayerheight
      end
   end
end)
1 Like

Change your code that checks LocalPlayer height to check the height of every player. You can use Players:GetPlayers() to get the table of players to iterate through.

Currently using a local script.

that code was designed for a local script

Yeah, was just letting you know about what I was using.

btw
when I say --record height
I mean, use the script you did to change the height of the player on the bar

What do I do in the module script?

local players = {}
--[[

Format:
players[#][2] = Height
players[#][1] = player (name)

]]
return players

forgot to mention, add a serverscript in SSS

local players = require(game:GetService("ReplicatedStorage"):WaitForChild("PlayerHeights"))

game.Players.PlayerAdded:Connect(function(player)
   local newPlayer = {player.Name}
   table.insert(newPlayer, 2, 0)
   table.insert(players, newPlayer)
end)

game.Players.PlayerRemoving:Connect(function(player)
   for _, playertable in pairs(players) do
      if playertable[1] == player.Name then
         playertable = nil
      end
   end
end)
1 Like

The positions of players are already replicated to eachothers’ clients.

so just clone ur moving thing and change appearance/height?

So I’ve managed to do some things and get it working, but every time a new player joins, it just freezes.

could you show your code? could be an issue with how youre looping it

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

if Player:WaitForChild("PlayerGui") then
	wait(1)
	while wait() do
		local Temp = Player.PlayerGui.HeightBar.Frame.Temp

		local Character = game.Workspace[Player.Name]
		local PrimaryPart = Character:FindFirstChild("HumanoidRootPart")
		local Height = math.ceil(PrimaryPart.Position.Y)
		Temp.Position = UDim2.new(-1.03, 0, 0.922 - Height / 230, 0)
		
		for _, player in pairs(Players:GetPlayers()) do
			game.ReplicatedStorage.DestroyLabel:Fire(player)
			local ImageLabel = script.ImageLabel:Clone()
			ImageLabel.Name = tostring(player.Name)
			ImageLabel.Parent = Player.PlayerGui.HeightBar.Frame
			local character = game.Workspace:WaitForChild(player.Name)
			local PrimaryPart = character:FindFirstChild("HumanoidRootPart")
			local Height = math.ceil(PrimaryPart.Position.Y)
			ImageLabel.Position = UDim2.new(-1.03, 0, 0.922 - Height / 230, 0)
		end
	end
end

are you ever deleting the old GUI labels?

Yeah I have an event firing just for that after the for loop line.

Use a heartbeat loop that tracks each player character and gets their relative height from the bottom of the tower. Then display it however you want on the GUI.

As mentioned, player characters automatically replicate so you should be able to do all of this clientside.

I already have that done, the only problem I’m facing right now is the freezing of this system when a new player joins. The whole thing freezes for the previous player.