Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

(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

1
Please place the code into a code block. M39a9am3R 3210 — 9y
0
^ Goulstem 8144 — 9y
0
Fixed, sorry guys. First question here. Rolerain 5 — 9y

Locked by Goulstem and M39a9am3R

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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)
0
Worked, thanks! Rolerain 5 — 9y
Ad