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

My team only GUi script wont work what went wrong exactly?

So I have a script in a Gui that shows up for a team and when the player switches team for a reason the Gui goes away so it's only for that team and the Script is in the ScreenGui and not the frame.

---Script---

--Key--
--Adult,Kid,Pet,Teenager = The teams.

--Put the script in the ScreenGui on nothing will work

if script.ScreenGui.Frame1.TeamColor == game.Teams.Adult.TeamColor then
	script.ScreenGui.Frame1.Visible = true
if script.ScreenGui.Frame1.TeamColor == game.Teams.Kid.TeamColor then
	script.ScreenGui.Frame1.Visible = false
if script.ScreenGui.Frame1.TeamColor == game.Teams.Pet.TeamColor then
	script.ScreenGui.Frame1.Visible = false
if script.ScreenGui.Frame1.TeamColor == game.Teenager.TeamColor then
	script.ScreenGui.Frame1.Visble = false
end
end
end
end

2 answers

local tabs = {
	Adult = true,
	Kid = false,
	Pet = false,
	Teenager = false
}

local frame = script.ScreenGui.Frame1

for i,v in next, tabs do 
	if frame.TeamColor == game.Teams[i].TeamColor then
		frame.Visible = v
	end
end

Hi i'm incredibly lazy to answer any questions and don't have any energy to explain what I did, feel free to downvote.

Basically learn tables and for loops

2 comments

1

what a great contradiction, you got upvotes instead dude

0

yeah that's pretty radical

Your script is currently this: (if this is true, then check if this is true then check if this is true...)

if script.ScreenGui.Frame1.TeamColor == game.Teams.Adult.TeamColor then
    	script.ScreenGui.Frame1.Visible = true
	if script.ScreenGui.Frame1.TeamColor == game.Teams.Kid.TeamColor then
	    	script.ScreenGui.Frame1.Visible = false
		if script.ScreenGui.Frame1.TeamColor == game.Teams.Pet.TeamColor then
		   		script.ScreenGui.Frame1.Visible = false
			if script.ScreenGui.Frame1.TeamColor == game.Teenager.TeamColor then
			    script.ScreenGui.Frame1.Visble = false
			end
		end
	end
end

Should be: (if this is true, otherwise, if this is true, do this, otherwise if this is true, do this etc.)

if script.ScreenGui.Frame1.TeamColor == game.Teams.Adult.TeamColor then
    script.ScreenGui.Frame1.Visible = true
elseif script.ScreenGui.Frame1.TeamColor == game.Teams.Kid.TeamColor then
    script.ScreenGui.Frame1.Visible = false
elseif script.ScreenGui.Frame1.TeamColor == game.Teams.Pet.TeamColor then
    script.ScreenGui.Frame1.Visible = false
elseif script.ScreenGui.Frame1.TeamColor == game.Teenager.TeamColor then
    script.ScreenGui.Frame1.Visble = false
end

2 comments

0

darn, 1 minute late to answer. reeee

0

soz

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