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

How to fix my team/group switch GUI? (Solved)

(code block fixed)

Hey there,

I've been having a issue with my team switch GUI. Basically, we have this GUI were you click, and it is supposed to switch your team to the other. (in this case, it should switch you to the "deep blue" team. But, for some reason, when I click it, it does nothing.

Here is my script:

function Click(mouse) 
if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(2544404) then 
script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Deep blue") 
end 
end 

script.Parent.MouseButton1Click:connect(Click) 

Thank you to anyone that can help! (note that I am a beginner scripter!) -Rolerain

3 comments

1

Please place the code into a code block.

0

^

0

Fixed, sorry guys. First question here.

1 answer

✓ Accepted answer

Please put your code in appropriate Lua code block next time


I can think of two reasons why that wouldn't work

1) - You're not indexing the player correctly.

2) - There is no team with a TeamColor of 'Deep Blue'


So just to make sure.. why dont you make this a localscript and access the player by game.Players.LocalPlayer. You should be using a localscript for the IsInGroup method anyways, because it returns live results, while using it in a server script returns cached results. Meaning that if the player leaves / joins the group while they're in the game then they don't have to rejoin.. if you use this in a localscript.


local id = 2544404 --Group ID
local teamColor = 'Deep blue' --TeamColor
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
	if plr:IsInGroup(id) then
		plr.TeamColor = BrickColor.new(teamColor)
	end
end)

1 comment

0

Worked, thanks!

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