Why is Gui not replicating to all clients and only the one?

The gif shows what the problem is. Player1 is clicking join team, and I’m cloning a playerCard from replicatedStorage to parent it to the frame, however Player2 doesn’t see that Player1’s card is on the team. Why is this happening and how can I fix it?

Gif of what I mean:
https://gyazo.com/3e730f3122ea748edc8ccb0d697ebd2d

Here’s my EventHandler Script for that:

local teamService = game:GetService("Teams")
local replicatedStorage = game:GetService("ReplicatedStorage")

local playerTeamedPraetorianEvent = game.ReplicatedStorage.Events.playerTeamedPraetorianEvent
playerTeamedPraetorianEvent.OnServerEvent:Connect(function(Player)
	print(Player.Name .. " playerTeamedPraetorianEvent")
	local joinTeamFrame = Player.PlayerGui.Main.JoinTeamFrame
	Player.Team = teamService.Praetorian
	Player.TeamColor = BrickColor.new("Mulberry")
	print(Player.Name .. " has joined the Praetorian team")
	
	local playerCard = replicatedStorage.Assets.purpleTemplate:Clone()
	playerCard.Parent = joinTeamFrame.PurpleTeam.ScrollingFrame
	wait(2)

	joinTeamFrame.joinSixth.Visible = false
	joinTeamFrame.joinPraetorian.Visible = false
	
	Player:LoadCharacter()
	game.ReplicatedStorage.Values.status.Value = ""
end)

local playerTeamedSixthEvent = game.ReplicatedStorage.Events.playerTeamedSixthEvent
playerTeamedSixthEvent.OnServerEvent:Connect(function(Player)
	print(Player.Name)
	local joinTeamFrame = Player.PlayerGui.Main.JoinTeamFrame
	Player.Team = teamService.Sixth
	Player.TeamColor = BrickColor.new("Maroon")
	print(Player.Name .. " has joined the Sixth team")

	local playerCard = replicatedStorage.Assets.redTemplate:Clone()
	playerCard.Parent = joinTeamFrame.RedTeam.ScrollingFrame
	wait(2)

	joinTeamFrame.joinSixth.Visible = false
	joinTeamFrame.joinPraetorian.Visible = false

	Player:LoadCharacter()
	game.ReplicatedStorage.Values.status.Value = ""
end)

Here is the client script for pressing the button which fires the Remove event in the event handler script (above)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local button = script.Parent
local teams = game:GetService("Teams")
local playerTeamedPraetorianEvent = game.ReplicatedStorage.Events.playerTeamedPraetorianEvent

button.MouseButton1Down:Connect(function()
	print("clicked mouse button 1 down")
	local Player = script.Parent.Parent.Parent.Parent.Parent

	playerTeamedPraetorianEvent:FireServer()
	script.Parent.Visible = false
	script.Parent.Parent.joinSixth.Visible = false
	
end)

Thanks

You can’t FireAllClients() from a client script, this is the work of a server script.

Check this out: RemoteEvent | Roblox Creator Documentation

I messed up. That actually isn’t what it was, I was doing some editing before making this post and now I realize that I never fixed that change. Still however, FireServer() does not work.

Edit: I’ve edited the original post to what was actually not working from before

Reason why Player2 can’t see the other Player that joined, is because in this part of the script

local joinTeamFrame = Player.PlayerGui.Main.JoinTeamFrame

You are getting the Player’s (the player that clicked) GUI, not all players.

You could either have a FireAllClients() event where it checks on client which players have joined a team or left (the game or the team). Or, get all players from the server script though I wouldn’t suggest that.

Why wouldn’t you suggest getting all players from the server script?

I don’t want to lie to you, because I’m not exactly sure if that would cause lag or what not. You could try that. But I believe, if you can do it on Client, why make it on server risking performance issues?

Again, this may cause no lag at all, but that’s my suggestion. Another person surely knows better than me, but at the end, it’s all up to you.

1 Like