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 fix a Team Switcher GUI that only switches you if you are in a Roblox group?

Basically, I want to be only able to join the (police) team, if I am in the (4994590) Roblox Group.

(Note: AnGardaSiochana is Irish Police)

This is the code in the TeamChange Local Script:

local RemoteEvent = game.ReplicatedStorage.ChangeTeam
local menuButton = script.Parent:WaitForChild("MenuButton")
local frame = script.Parent:WaitForChild("Frame")
-- colours
local AnGardaSiochanaColor = "Electric blue"
local IrishCitizenColor = "Lime green"
 frame.AnGardaSiochana.MouseButton1Click:Connect (function()
	RemoteEvent:FireServer(BrickColor.new(AnGardaSiochanaColor))
end)
frame.IrishCitizen.MouseButton1Click:Connect (function()
	RemoteEvent:FireServer(BrickColor.new(IrishCitizenColor))
end)

menuButton.MouseButtonClick:Connect(function()
	frame.Visible = not frame.Visible
end)

The Script in the ServerScriptService:

game.ReplicatedStorage.ChangeTeam.OnServerEvent:Connect(function(player, teamColor)
	player.TeamColor = teamColor
	player:LoadCharacter()
end)

And the spawn for the team that you can only join if you are in the group:

function Enter(newPlayer) 
if newPlayer:IsInGroup(4994590) then 
    newPlayer.TeamColor=script.Parent.TeamColor 
    end 
end

For some reason, it doesn’t work and does not let you switch to any teams at all. Please let me know if you have any suggestions on how to fix this, as I am a beginner at scripting. Thanks!

1 answer

Try this

function Enter(newPlayer,TeamColor)
	if newPlayer:IsInGroup(4994590) then
	    newPlayer.TeamColor= TeamColor
	end
end
game.ReplicatedStorage.ChangeTeam.OnServerEvent:Connect(Enter)

1 comment

0

Just tried that and unfortunately it doesn’t work. When I click the Police label in the GUI, nothing happens at all.

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