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?
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?
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Thank you
Or you can use Team.PlayerAdded in a server script