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

How to make gui visible for a certain team?

Asked by 1 year ago

This is what i've tried script in serverscriptservice

for i, v in pairs (game.Teams:WaitForChild("D"):GetPlayers()) do
script.parent.parent.parent.StarterGui.ScreenGui.Enabled = true
end

Team name is D Don't know what I am doing wrong?

1 answer

Log in to vote
2
Answered by 1 year ago

I'm trying to say this respectfully but, in my opinion, what you're doing is entirely wrong.

First, you're enabling it in the StarterGui, not the PlayerGui of any user. Second, you should always use .Parent instead of .parent, as far as I know it's a deprecated version of .Parent. Third, you should use a LocalScript for something like this.

For example, put a LocalScript in the ScreenGui that you only want users in the team to see and try this:

local player = game.Players.LocalPlayer
if player.Team == game.Teams.D then
    script.Parent.Enabled = true
end

Or if you want it to automatically detect team changes you could use :GetPropertyChangedSignal, for example:

local player = game.Players.LocalPlayer

local function update()
    if player.Team == game.Teams.D then
        script.Parent.Enabled = true
    else
        script.Parent.Enabled = false -- Since I'm guessing you don't want players that aren't in that team to see this gui
    end
end

player:GetPropertyChangedSignal("Team"):Connect(update) -- To check whenever the team of the player changes
update() -- To check once before it changes, since otherwise it would *only* check when a team changes
0
Thank you blue_bunny0fficl 98 — 1y
0
Or you can use Team.PlayerAdded in a server script T3_MasterGamer 2189 — 1y
Ad

Answer this question