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

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

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

✓ Accepted answer

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)

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