Switch team GUI kills all players in the game?
I have created a GUI where you can switch teams. I have made it where if you click on any team it kills you so you can respawn at the team spawn with the team weapons/tools for the team you chose. But when I tested this out in game via ROBLOX Player with a friend. He decided to switch teams. When he clicked the button it killed all the players in the game.
However it did make him switch teams and I was still on the team I spawned as/chose. The problem is that I just want only the person that switches teams to be killed instead of every single person in the game.
Here is a picture of the items in the GUI:
LocalScript inside TextButton:
01 | local TextButton = script.Parent |
02 | local Frame = TextButton.Parent |
03 | local player = game.Players.LocalPlayer |
07 | TextButton.BackgroundColor 3 = Color 3. fromRGB( 176 , 176 , 176 ) |
12 | TextButton.BackgroundColor 3 = Color 3. fromRGB( 226 , 226 , 226 ) |
16 | TextButton.MouseButton 1 Click:connect( function () |
17 | player.TeamColor = BrickColor.new( "Forest green" ) |
19 | for i,v in pairs (game.Players:GetChildren()) do |
20 | v.Character:BreakJoints() |
25 | script.Parent.MouseEnter:connect(hover) |
26 | script.Parent.MouseLeave:connect(hover 2 ) |
All of the other LocalScripts inside of the TextButtons are the same except the TeamColor = BrickColor.new("") is different.
Please help me, Thank you!