Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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:

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!

2 comments

0

Of course it's going to kill all the players because you literally tell the script to do exactly that lol

0

...are you going to help me fix it or you just gonna sit there and be rude about it?

1 answer

✓ Accepted answer

Heheh, well, instead of saying

v.Character:BreakJoints()

I would say

player.Character:BreakJoints()

This discussion is preserved as it was. New answers, comments, and votes are closed.