I am trying to set two teams (thieves and police). The user can choose the team with GUI at the start of a game. When the user clicks on the GUI button for a team it does not work for some reason, and I am not getting any errors, can anyone help?
Thanks.
This is the local script located in the StarterGui:
-- Team changer GUI script local remoteEvent = game.ReplicatedStorage.teamChanger local teamGuiFrame = script.Parent:WaitForChild("Frame") --Teams local thieveColor = "Deep Orange" local policeColor = "Deep Blue" teamGuiFrame.ThieveButton.MouseButton1Click:Connect(function() remoteEvent:FireServer(BrickColor.new(thieveColor)) end) teamGuiFrame.PoliceButton.MouseButton1Click:Connect(function() remoteEvent:FireServer(BrickColor.new(policeColor)) end)
And this is the serverSide script:
--Team Changer game.ReplicatedStorage.teamChanger.OnServerEvent:Connect(function(player,teamColor) player.TeamColor = teamColor player:LoadCharacter() end)
Here is the image of the Explorer: https://ibb.co/7KP8Jxd
For the local script on your 7th and 8th line, you've made a mistake for Deep orange and Deep blue, roblox is very sensetive with capitals, and you've used a capital for orange and blue, it may be that problem
-- Team changer GUI script local remoteEvent = game.ReplicatedStorage.teamChanger local teamGuiFrame = script.Parent:WaitForChild("Frame") --Teams local thieveColor = "Deep orange" local policeColor = "Deep blue" teamGuiFrame.ThieveButton.MouseButton1Click:Connect(function() remoteEvent:FireServer(BrickColor.new(thieveColor)) end) teamGuiFrame.PoliceButton.MouseButton1Click:Connect(function() remoteEvent:FireServer(BrickColor.new(policeColor)) end)
Instead of trying to get the team color, get the team instead
It will probably look like this:
local script
local remoteEvent = game.ReplicatedStorage.teamChanger local teamGuiFrame = script.Parent:WaitForChild("Frame") local teamService = game:GetService(“Teams”) local thieveTeam = teamService.Name_of_Thieve_Team local policeTeam = teamService.Name_of_Police_Team teamGuiFrame.ThieveButton.MouseButton1Click:Connect(function() remoteEvent:FireServer(thieveTeam) end) teamGuiFrame.PoliceButton.MouseButton1Click:Connect(function() remoteEvent:FireServer(policeTeam) end)
Server Script
game.ReplicatedStorage.teamChanger.OnServerEvent:Connect(function(player,team) player.Team = team player:LoadCharacter() end)