While developing a game, I came across a problem regarding team switching. The issue is that when players click on the team switching button, as shown in the video, they spawn in the incorrect location. However, when using admin commands to switch teams, the player spawns in the correct location. This issue appears to affect all teams and buttons displayed in the video. I would greatly appreciate any help in resolving this matter.
Code used in the Image Buttons:
script.parent.mouse1click:connect(function()
game.players.localplayer.teamcolor = brickcolor.new("Industrial White") --civillian team
"game.players.localplayer.teamcolor" was used for the all the other teams.
Not sure where you got the scripts from but I don’t think mouse1click is an actual event for ImageButtons. Maybe you meant to use MouseButton1Click instead?
Also, make sure your code’s casing (your script is in all lowercase) is properly formatted in the actual script otherwise this won’t work. Even though some things can be referenced in camelCase due to their deprecated counterparts still existing, you’ll find that the Roblox API is mostly PascalCase now.
Just to be clear, do you have this code set up in LocalScripts that aren’t disabled?
Assuming that’s the case, then have you also made sure to double check your SpawnLocations’ TeamColor property to make sure they are assigned to the correct teams?
Finally, if everything above is in check, have you made sure that the local scripts themselves are actually running/the event is firing? (You can try adding a print at the beginning of the scripts and another print in the event listener)
Do you have any SpawnLocation objects where the Neutral property is set to true, this makes the SpawnLocation selectable as a spawn anyone regardless of team
All scripts for team switching are local scripts. And yes, all spawn locations are set to the right team color. However, I tried added print("Changed Team!") it is printed correctly but the same issue shown on the video happens. When I try to reset I do not spawn in the right spawn location.