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)
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.
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)
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.
@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.
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.
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
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.)