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

When the user select a team, the system is not updating. Can anyone help?

Asked by 3 years ago
Edited 3 years ago

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
02local remoteEvent = game.ReplicatedStorage.teamChanger
03local teamGuiFrame = script.Parent:WaitForChild("Frame")
04 
05--Teams
06 
07local thieveColor = "Deep Orange"
08local policeColor = "Deep Blue"
09 
10teamGuiFrame.ThieveButton.MouseButton1Click:Connect(function()
11    remoteEvent:FireServer(BrickColor.new(thieveColor))
12end)
13 
14 
15teamGuiFrame.PoliceButton.MouseButton1Click:Connect(function()
16    remoteEvent:FireServer(BrickColor.new(policeColor))
17end)

And this is the serverSide script:

1--Team Changer
2 
3game.ReplicatedStorage.teamChanger.OnServerEvent:Connect(function(player,teamColor)
4    player.TeamColor = teamColor
5    player:LoadCharacter()
6end)

Here is the image of the Explorer: https://ibb.co/7KP8Jxd

0
Are you receiving any errors in the Output window? COUNTYL1MITS 312 — 3y
0
No, I am not getting any errors. badcraftyt 21 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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
02local remoteEvent = game.ReplicatedStorage.teamChanger
03local teamGuiFrame = script.Parent:WaitForChild("Frame")
04 
05--Teams
06 
07local thieveColor = "Deep orange"
08local policeColor = "Deep blue"
09 
10teamGuiFrame.ThieveButton.MouseButton1Click:Connect(function()
11    remoteEvent:FireServer(BrickColor.new(thieveColor))
12end)
13 
14 
15teamGuiFrame.PoliceButton.MouseButton1Click:Connect(function()
16    remoteEvent:FireServer(BrickColor.new(policeColor))
17end)
0
I tried it and still nothing. badcraftyt 21 — 3y
Ad
Log in to vote
0
Answered by
1JBird1 64
3 years ago

Instead of trying to get the team color, get the team instead

It will probably look like this:

local script

01local remoteEvent = game.ReplicatedStorage.teamChanger
02local teamGuiFrame = script.Parent:WaitForChild("Frame")
03 
04local teamService = game:GetService(“Teams”)
05 
06local thieveTeam = teamService.Name_of_Thieve_Team
07local policeTeam = teamService.Name_of_Police_Team
08 
09teamGuiFrame.ThieveButton.MouseButton1Click:Connect(function()
10   remoteEvent:FireServer(thieveTeam)
11end)
12 
13 
14teamGuiFrame.PoliceButton.MouseButton1Click:Connect(function()
15  remoteEvent:FireServer(policeTeam)
16end)

Server Script

1game.ReplicatedStorage.teamChanger.OnServerEvent:Connect(function(player,team)
2 player.Team = team
3 player:LoadCharacter()
4end)
0
Hopefully this works out for you 1JBird1 64 — 3y

Answer this question