Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do I make a Gui not appear to a team?

Asked by
pwnd64 106
9 years ago

Hi, sorry for having another question so quickly but I'm only learning. I want to make a gui not appear to a team because I have a visitor's team for my place and I don't want them to be able to harm the group team, allies, or raiders. this is my script right now, in a script under the StarterGui-

function PlayerAdded(player) if player.TeamColor == ("Mid gray") then script.Parent.SelectGun:Destroy() end end

It seems to have no effect,.

Thanks for checking it out.

Thanks to ImageLabel for sorting my issue! He got it perfect in his comment, with a step by step guide.

1 answer

Log in to vote
1
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

You can always try parenting the Gui itself to ReplicatedStorage and only cloning it to the PlayerGuis of those that matched the set requirements.


local replicated = game:GetService('ReplicatedStorage')
local guiFile = 'SelectGun' 
local players = game:GetService('Players')
local exempt = BrickColor.new('White') 

Edit exempt to TeamColor that should be exempt from distribution (above)

players.PlayerAdded:connect(function (player)
    local playerGui = player:WaitForChild('PlayerGui')
    local clone = replicated:WaitForChild(guiName)

    player.Changed:connect(function (property)
        if property == 'TeamColor' then
            if (not player[property] == exempt) then
                if (not playerGui:FindFirstChild(guiFile)) then
                    clone:Clone().Parent = playerGui
                end
            end 
        end
    end)
end)

line 2 = finding or waiting for the player's PlayerGui

line 3 = finding or waiting for the pre-defined "gui" we want to clone

line 4 = fires when a property of player is changed

line 5 = if the changed property is TeamColor then go on

line 6 = if the TeamColor's set value does not equal the pre-defined exempt TeamColor value then go on

line 7 = if the gui doesn't already exist in the player's PlayerGui then go on

line 8 = clone the pre-defined guiFile

done!


0
Thanks a lot! I also really appreciate how you walked me through at the end, I'm just beginning to learn Lua so this is a really big help! Thank you so much! pwnd64 106 — 9y
0
Sorry for being a bit bothersome too! pwnd64 106 — 9y
0
Wow that actually makes sense! I just put what i thought was correct. Im also a beginner. TrollD3 105 — 9y
0
Np ImageLabel 1541 — 9y
Ad

Answer this question