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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
Asceylos 562 Moderation Voter
4 years ago
Edited 4 years ago

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)
1
Question, How can I check if they are in either mulitple teams? Mrmonkeyman120 65 — 4y
0
Thanks for the answer! Mrmonkeyman120 65 — 4y
0
By adding "or plr.Team.Name == 'OtherTeam'sName'" to the if statement. Asceylos 562 — 4y
0
Ah thanks! Mrmonkeyman120 65 — 4y
Ad

Answer this question