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

How do you fix a Team Switcher GUI that only switches you if you are in a Roblox group?

Asked by
0jd95 0
5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Try this

function Enter(newPlayer,TeamColor)
    if newPlayer:IsInGroup(4994590) then
        newPlayer.TeamColor= TeamColor
    end
end
game.ReplicatedStorage.ChangeTeam.OnServerEvent:Connect(Enter)
0
Just tried that and unfortunately it doesn’t work. When I click the Police label in the GUI, nothing happens at all. 0jd95 0 — 5y
Ad

Answer this question