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:
01 | -- Team changer GUI script |
02 | local remoteEvent = game.ReplicatedStorage.teamChanger |
03 | local teamGuiFrame = script.Parent:WaitForChild( "Frame" ) |
04 |
05 | --Teams |
06 |
07 | local thieveColor = "Deep Orange" |
08 | local policeColor = "Deep Blue" |
09 |
10 | teamGuiFrame.ThieveButton.MouseButton 1 Click:Connect( function () |
11 | remoteEvent:FireServer(BrickColor.new(thieveColor)) |
12 | end ) |
13 |
14 |
15 | teamGuiFrame.PoliceButton.MouseButton 1 Click:Connect( function () |
16 | remoteEvent:FireServer(BrickColor.new(policeColor)) |
17 | end ) |
And this is the serverSide script:
1 | --Team Changer |
2 |
3 | game.ReplicatedStorage.teamChanger.OnServerEvent:Connect( function (player,teamColor) |
4 | player.TeamColor = teamColor |
5 | player:LoadCharacter() |
6 | 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
01 | -- Team changer GUI script |
02 | local remoteEvent = game.ReplicatedStorage.teamChanger |
03 | local teamGuiFrame = script.Parent:WaitForChild( "Frame" ) |
04 |
05 | --Teams |
06 |
07 | local thieveColor = "Deep orange" |
08 | local policeColor = "Deep blue" |
09 |
10 | teamGuiFrame.ThieveButton.MouseButton 1 Click:Connect( function () |
11 | remoteEvent:FireServer(BrickColor.new(thieveColor)) |
12 | end ) |
13 |
14 |
15 | teamGuiFrame.PoliceButton.MouseButton 1 Click:Connect( function () |
16 | remoteEvent:FireServer(BrickColor.new(policeColor)) |
17 | end ) |
Instead of trying to get the team color, get the team instead
It will probably look like this:
local script
01 | local remoteEvent = game.ReplicatedStorage.teamChanger |
02 | local teamGuiFrame = script.Parent:WaitForChild( "Frame" ) |
03 |
04 | local teamService = game:GetService(“Teams”) |
05 |
06 | local thieveTeam = teamService.Name_of_Thieve_Team |
07 | local policeTeam = teamService.Name_of_Police_Team |
08 |
09 | teamGuiFrame.ThieveButton.MouseButton 1 Click:Connect( function () |
10 | remoteEvent:FireServer(thieveTeam) |
11 | end ) |
12 |
13 |
14 | teamGuiFrame.PoliceButton.MouseButton 1 Click:Connect( function () |
15 | remoteEvent:FireServer(policeTeam) |
16 | end ) |
Server Script
1 | game.ReplicatedStorage.teamChanger.OnServerEvent:Connect( function (player,team) |
2 | player.Team = team |
3 | player:LoadCharacter() |
4 | end ) |