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

Why does this not check his/her rank and let her click and open the door?

I have a door script, that opens the door when you click the click detector. Pretty simple. But, for my game, I need it so only people on a specific team can open the specific door. And also, Multiple teams to open one door would be good. I have a Server Script inside of the click detector that sends info to the other Server Script to actually make the thing move. But, Why isn't this working still?

Original script, (Working):

game.ServerScriptService.RegisterToDoorService:Invoke(script)

New script, (Not working.):

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if plr.Team == "Patient" then
game.ServerScriptService.RegisterToDoorService:Invoke(script)
end
end)

1 answer

✓ Accepted answer

It is because the Team property of Player returns the Team instance. You can fix this by simply adding ".Name".

Fixed script:

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    if plr.Team.Name == "Patient" then
game.ServerScriptService.RegisterToDoorService:Invoke(script)
end
end)

4 comments

1

Question, How can I check if they are in either mulitple teams?

0

Thanks for the answer!

0

By adding "or plr.Team.Name == 'OtherTeam'sName'" to the if statement.

0

Ah thanks!

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