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

How do you exactly type a code for ScreenGUIs' for certain teams?

Hello! I am a beginner scripter so before you try to help me, please dont judge my learnings on Lua and others!

Hi! i was trying to make a script that will show a GUI enabled for 10 Seconds then close after 10 Seconds however there will be different GUIS per team so thats why im trying to do an If statement, the problem is that i had no errors and it didnt work either. INFO: C - ScreenGUI (Was enabled false at default) Cadets - Team

local StarterGUI = game.StarterGui

if game.Players.Parent.Teams.Cadets == true then  -- If player is assigned on "Cadets" team
	StarterGUI.C.Enabled = true
	wait(10)
	StarterGUI.C.Enabled = false
end

im not sure how to fix this code i wrote but i can sure use some help! Please reply asap if you know what i have to fix or do! Thanks!

5 comments

0

FYI; The statement i wrote next to the If statement was NOT part of the command, just some info.

0

Is this a localscript or a server sided script?

0

Is this a localscript or a server sided script?

0

Is this a localscript or a server sided script?

0

oh god the server broke lol so thats why thers so many comments

1 answer

local StarterGUI = game.StarterGui

if game.Players.Parent.Teams.Cadets == true then  -- game.Players.Parent is incorrect. game.Players.Parent = game.
    StarterGUI.C.Enabled = true
    wait(10)
    StarterGUI.C.Enabled = false
end


--Correct code

-- Dont forget you have to add the teams service to your game on your own. I provided a link below to help with that.

local player = game.Players.LocalPlayer
local team = game:GetService("Teams")
local Cadets = team.Cadets
if player.Team == team.Cadets then
	StarterGUI.C.Enabled = true
    wait(10)
    StarterGUI.C.Enabled = false
end

https://developer.roblox.com/en-us/articles/Player-Spawns-and-Teams

4 comments

0

Hi Wizy! I tried your script on a local script and a normal SS Service script, it says that there is an error on line 15 that it cannot identify what is "player" but still, thanks for trying to help!

0

That is because you have to define player, it doesn't just exist. In a local script, local player = game.Players.LocalPlayer

0

I edited my post to show you. Very simple

0

@WizyTheNinja this still won't work. make sure to change StarterGui.C to player.PlayerGui:WaitForChild("C")

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