UI is not updating for all the Clients. RemoteEvents issue..?

Heya.

I’ve been working on an overhead UI that is cloned in each player’s PlayerGui and its Adornee is set to their Head.

However, when I toggle the UI visibility on and off, it is only shown for the Client, but not other players. I have tried RemoteEvents but it doesn’t seem to be working at all.

The visibility toggle is dependent on a Value in ReplicatedStorage called VotingTime, whether it is true or not.

--ServerScript

local RS = game:GetService("ReplicatedStorage")
local UI = RS:FindFirstChild("UI")
local VotingTime = RS:FindFirstChild("VotingTime")

local RemoteEvent = RS:FindFirstChild("RemoteEvent")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		UI:Clone().Parent = player.PlayerGui
		player.PlayerGui.UI.Adornee = character.Head
		
		VotingTime.Changed:Connect(function()
			RemoteEvent:FireAllClients(player)
		end)
	end)
end)

And then the LocalScript placed within the UI.

--LocalScript
local RS = game:GetService("ReplicatedStorage")
local votingTime = RS:FindFirstChild("VotingTime")
local RemoteEvent = RS:FindFirstChild("RemoteEvent")

local main = script.Parent.Parent

RemoteEvent.OnClientEvent:Connect(function(player)
    if votingTime.Value == true then
        main.Visible = true
    else
        main.Visible = false
    end
end)

This is the result that happens:

How do I solve this problem? I have also tried a FireServer method but it gave me the same result. How do I go about this?

2 Likes

Where is the LocalScript placed?

Idk if this is the issue, but you don’t have to pass the argument player, as it fires the remoteEvent to all clients

Screen Shot 2020-08-27 at 7.36.07 PM

1 Like

You’re setting the GUI visibility to true on a local script, therefore it will be visible to the local player. You don’t need to use a remote event, set the visibility of the GUI on the server.

1 Like

You’re trying to change the visibility on the client. So thats why only the client can see it and others can’t.

Edit: @Blunce and i just commented at the same time :sweat_smile:

2 Likes

He fires a RemotEvent to all clients. It’s like looping and running the code through each client. I am not quite sure if it could be the problem, but it may be.

You can use only a ServerScript by changing your ServerScript code to this:

local RS = game:GetService("ReplicatedStorage")
local UI = RS:FindFirstChild("UI")
local VotingTime = RS:FindFirstChild("VotingTime")

local RemoteEvent = RS:FindFirstChild("RemoteEvent")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		UI:Clone().Parent = player.PlayerGui
		player.PlayerGui.UI.Adornee = character.Head
		
		VotingTime.Changed:Connect(function()
		
			for _, v in ipairs(game.Players:GetChildren()) do
				
				if v:IsA("Player") and not v == nil then
					
					local playerGui = v.PlayerGui
					
					playerGui.ScreenGui.Frame.Visible = true -- Reference your UI.
				end
			end
		end)
	end)
end)

Unfortunately now it doesn’t seem to be working at all.

I’m looking at the PlayerGui while the game is running and now the Main frame isn’t being toggled at all.

I figured this too, but apparently when attempting this with a Server script, it gives no result. In fact, I’m pretty sure it breaks it altogether, because the Main frame is no longer toggling.

Did you reference your UI where I commented?

You have to toggle it for every player. Iterate over the current players in game, go into their PlayerGui and set the visibility to true.

1 Like

@Blunce @XDvvvDX I have iterated through all of the PlayerGuis, it fixes it halfway, but only returns back to square one where only the Client can see the change.

Script:

local RS = game:GetService("ReplicatedStorage")
local UI = RS:FindFirstChild("UI")
local VotingTime = RS:FindFirstChild("VotingTime")


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		UI:Clone().Parent = player.PlayerGui
		player.PlayerGui.UI.Adornee = character.Head
		
		VotingTime.Changed:Connect(function()
			if VotingTime.Value == true then
				for _, v in ipairs(game.Players:GetChildren()) do
					if v:IsA("Player") and v ~= nil then
						local playerGui = v.PlayerGui
						playerGui.UI.Main.Visible = true -- Reference your UI.
					end
				end
			else
				for _, v in ipairs(game.Players:GetChildren()) do
					if v:IsA("Player") and v ~= nil then
						local playerGui = v.PlayerGui
						playerGui.UI.Main.Visible = false -- Reference your UI.
					end
				end
			end
		end)
	end)
end)

I’m really scratching my head with this one because I have no idea what it can possibly be. I can activate and uncopylock this place if that helps.

2 Likes

Yes, please do I would like to see the code.

1 Like

Is the output returning anything?

Can you please explain to me what is supposed to happen and what in the game is happening?

Okay, so you should probably not put the billboard gui on the playergui, instead you could put it somewhere on a part above the person so that it could be manipulated

Absolutely.

I’m creating a concept where every it is time to vote, each player has a suspicion meter. Hence, the billboardguis. So the system goes as this:

  • Server script in the ServerScriptService is a loop turning the VotingTime value on and off for testing the functionality of the game concept. Think of it as a cycle script.

See here:

local RS = game:GetService("ReplicatedStorage")
local VotingTime = RS:FindFirstChild("VotingTime")

while true do
    wait(3)
    VotingTime.Value = true
    wait(3)
    VotingTime.Value = false
end
  • There is then another separate script that controls the status of the UIs, which is what this post is about.

There’s not much functionality to the game. I’m just exploring how I can make the UI appear to all players when it comes to voting time. That way the suspicion meter can encourage them to vote or not on a specific person. (Though, I’m just worrying on the visibility aspect first.)

I was recommended to not do that as that is a security issue. Though, I am open to hear a second opinion.

1 Like