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!
Try this
function Enter(newPlayer,TeamColor) if newPlayer:IsInGroup(4994590) then newPlayer.TeamColor= TeamColor end end game.ReplicatedStorage.ChangeTeam.OnServerEvent:Connect(Enter)