Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Switch team GUI kills all players in the game?

Asked by 7 years ago

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!

0
Of course it's going to kill all the players because you literally tell the script to do exactly that lol Perci1 4988 — 7y
0
...are you going to help me fix it or you just gonna sit there and be rude about it? PvPNinjaDragon 35 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Heheh, well, instead of saying

v.Character:BreakJoints()

I would say

player.Character:BreakJoints()

Ad

Answer this question