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

How do I make this Script only Functional for a Group?

Asked by
SirPaco 66
9 years ago
local Player = script.Parent.Parent.Parent.Parent.Parent
local teamcolor = "Bright green"

function onClick()
    if Player.TeamColor == BrickColor.new(teamcolor) then
    return
    else
    Player.TeamColor = BrickColor.new(teamcolor)
    Player.Character.Humanoid.Health = 0
    end
end

script.Parent.MouseButton1Down:connect(onClick)

1 answer

Log in to vote
0
Answered by 9 years ago
local Player = script.Parent.Parent.Parent.Parent.Parent -- I'm guessing this isn't a localscript, but if it is I would use game.Players.LocalPlayer
local teamcolor = "Bright green"
local groupID = 0 -- put the group ID here
function onClick()
    if Player.TeamColor == BrickColor.new(teamcolor) and Player:IsInGroup(groupID) then
    return
    else
    Player.TeamColor = BrickColor.new(teamcolor)
    Player.Character.Humanoid.Health = 0
    end
end

script.Parent.MouseButton1Down:connect(onClick)

Player:IsInGroup()

let me write a little explanation on this wonder. Well, there's nothing to explain, but it checks if the Player is in the group ID put in the parameters.

Ad

Answer this question