Cloning into PlayerGui

So I am trying to make a system where if you’re on a team you get tools and gui’s specifically for that team.

The tools work but not guis.

THE SCRIPT IS IN SERVERSCRIPTSERVICE

Script

for _, Player in ipairs(game.Players:GetPlayers()) do
Player.CharacterAdded:connect(function() onCharacterAdded(Player) end)
end

function onPlayerAdded(Player)
Player.CharacterAdded:connect(function() onCharacterAdded(Player) end)
end
game.Players.PlayerAdded:connect(onPlayerAdded)

function onCharacterAdded(Player)
for _, Team in ipairs(game.Teams:GetChildren()) do
if Team.TeamColor == Player.TeamColor then
for _, Object in ipairs(Team.TeamGuis:GetChildren()) do
Object:Clone().Parent = Player.PlayerGui
end
break
end
end
end

j

Try this in onPlayerAdded:Connect(function()

local ui = player:WaitForChild("PlayerGui") --Loads gui
for I, v in pairs(Teams.Vice President.TeamGuis:GetChildren()) do
       v:Clone().Parent = ui
    end

)

It might not be exactly that, but close. Parent the ScreenGui to the player’s “PlayerGui”. You’ll have to check if the player is in your Vice President team first though.

The script is supposed to get all guis from any team the player and insert them not just the VP team.

Ok, so:

local ui = player:WaitForChild("PlayerGui") --Loads gui
local team = player.Team
local guis = team:WaitForChild("TeamGuis")
for I, v in pairs(guis:GetChildren()) do
       v:Clone().Parent = ui
    end

Doesn’t work.

Perhaps writing a local script inside the gui would be better. Just check for the team, and it it is the specified team, make the visible property of your frame true.

If I did that on a local script it would be easy for exploiters to get access to it unless I call a remote event from the local script

You shouldn’t be concerned about exploiters getting access to your UI because whatever you put in place will have its workarounds. Remember exploiters can run code, control remote traffic and directly fire remotes. If your UI has such important features that you don’t want an exploiter seeing them you should take a different approach at making your system.

All visual stuff should be ran on the client and all the important ‘exploitable’ parts of the system should be ran on the server with the appropriate sanity checks in place.


With the system you are trying to make it would be best if you controlled all your UI changes on the client instead of involving the server. @Someperson576 solution seems like the best approach to take providing you set up the system correctly with the correct server sided checks in place.

If I recall correctly, the server can’t see PlayerGui, or anything like that. You’d have to use a LocalScript. If you wan’t to use a normal Script as well, you’d have to use a RemoteEvent.

I did this, isnt working.

LOCAL SCRIPT LOCATED IN STARTERGUI

Script

for _, Player in ipairs(game.Players:GetPlayers()) do
Player.CharacterAdded:connect(function() onCharacterAdded(Player) end)
end

function onPlayerAdded(Player)
Player.CharacterAdded:connect(function() onCharacterAdded(Player) end)
end
game.Players.PlayerAdded:connect(onPlayerAdded)

function onCharacterAdded(Player)
for _, Team in ipairs(game.Teams:GetChildren()) do
if Team.TeamColor == Player.TeamColor then
Player.PlayerGui.Radio.Enabled = true
end
break
end
end