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:
local TextButton = script.Parent local Frame = TextButton.Parent local player = game.Players.LocalPlayer function hover() TextButton.BackgroundColor3 = Color3.fromRGB(176,176,176) end function hover2() TextButton.BackgroundColor3 = Color3.fromRGB(226,226,226) end TextButton.MouseButton1Click:connect(function() player.TeamColor = BrickColor.new("Forest green") Frame.Visible = false for i,v in pairs(game.Players:GetChildren()) do v.Character:BreakJoints() end end) script.Parent.MouseEnter:connect(hover) script.Parent.MouseLeave:connect(hover2)
All of the other LocalScripts inside of the TextButtons are the same except the TeamColor = BrickColor.new("") is different.
Please help me, Thank you!
Heheh, well, instead of saying
v.Character:BreakJoints()
I would say
player.Character:BreakJoints()