#Changing teams

18 messages · Page 1 of 1 (latest)

crisp talon
#

Having a problem changing a players team through a teamgui every part of the code goes through from start to end, but the team doesn't change
tried doing it in 2 ways 1. sending a remotevent from the client upon clickong to the server 2. from clientside without server just for the purpose of seeing if the team change works at all, but nothing worked
client

for i,v in pairs(TeamGui:GetChildren()) do
    v.MouseButton1Click:Connect(function()
        PlayerTeamChangeRemoteEvent:FireServer(v.Name)
    end)
end

server

PlayerTeamChangeRemoteEvent.OnServerEvent:Connect(function(player,button_name)
    game.Players[tostring(player)].Team = game.Teams[button_name]
end)

keen ruinBOT
#

studio** You are now Level 4! **studio

cursive depot
#

Are there any errors

#

Also there is no need to do the

game.Players[tostring()].Team

When you can just

player.Team
crisp talon
#

no errors

cursive depot
#

Can you add a print in the server script to confirm the event fires at all?

#

Also the teams have to be created beforehand in explorer inside teams

crisp talon
#

already checked the print part and everything fires

#

and teams have been created

#

prior

cursive depot
#

It could be because game.Teams[button_name] returns nil.

Try adding print(game.Teams[button_name]) to see if it actually finds the team

crisp talon
#

returns Blue as it should

#

or red

cursive depot
#

That's weird. I have no clue then

severe wasp
#

nowdays roblox is getting weird

#

really

crisp talon
#

might not be a problem with the scripts themselves but with the team setup since even though I have 2 teams created only one of them shows up ingame

crisp talon
#

ok the problem was every team having the same color code