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

How do I make my door open for certain teams only?

I have tried various solutions, even keycards and such but I'm completely lost. Here's my code:

function onClicked ()
   script.Parent.Parent.Parent.Parent.mistake.m.HingeConstraint.TargetAngle = -90
   wait(3)
   script.Parent.Parent.Parent.Parent.mistake.m.HingeConstraint.TargetAngle = 0
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

The script is functional, but I'd like for it to only work when certain (several) teams click on it.

2 answers

You need to check the team before opening the door

local TeamName = "" -- Make sure your teams are in the teams folder
function onClicked (Player)
	if Player.Team.Name == Team.Name then
	   script.Parent.Parent.Parent.Parent.mistake.m.HingeConstraint.TargetAngle = -90
	   wait(3)
	   script.Parent.Parent.Parent.Parent.mistake.m.HingeConstraint.TargetAngle = 0
	end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

script.Parent.ClickDetector.MouseClick:connect(onClicked) This line is wrong. The lowercase :connect() is depricated. Use :Connect(), scripting is case-sensitive as you should know. And check the above answer to check the team.

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