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

How do I make this script so only people in a certain group and click and open the door?

Asked by 9 years ago

I would like this script so only people in a certain group and/or team can click this, but not everyone that's in the game, but I can't seem to figure it out. I'm drawing a blank. xD

Door = script.Parent.Parent.Door

function onClicked()
    Door.Transparency = 1
    Door.CanCollide = false
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Well, from the MouseClick function, you can get the Player.

Door = script.Parent.Parent.Door
id = 1337 -- Group Id
open = false

script.Parent.ClickDetector.MouseClick:connect(function(p)
    if p:IsInGroup(id) and p.TeamColor == BrickColor.new("Really red") then -- BrickColor of the TeamColor
        if open == false then
            Door.Transparency = 1
            Door.CanCollide = false
            open = true
        elseif open == true then
            Door.Transparency = 0
            Door.CanCollide = true
            open = false
        end
    end
end)
Ad

Answer this question