Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make gui visible for a certain team?

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

✓ Accepted answer

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

2 comments

0

Thank you

0

Or you can use Team.PlayerAdded in a server script

This discussion is preserved as it was. New answers, comments, and votes are closed.