I need a button for a border game in the admission booth to open a door, the problem is that any player can zoom out and press it to open then door. That’s when I realized I needed a button that will only work if a player on a certain team (in this case “admission”) pressed it. I have contacted multiple friends and tryed multiple scripts myself but unfortunately, nothing works.
If you are using a ClickDetector, it will return the player who clicks it as an argument, so click will be the player. And on normal script, you can’t do game.Players.LocalPlayer.
Your parameter, click inside the function is automatically going to be the player. You do not need to and cannot call game.Players.LocalPlayer from a server-sided script.
Therefore, saying click.Parent is going to refer to the folder game.Players, as it is where the player is kept. I have included an example below on how to go about this.
local group = script.Parent.Parent.Parent
function onClick(click)
if click.TeamColor == BrickColor.new("Bright green") then
group.Parent.Door.Door.Transparency = 1
group.Parent.Door.Door.CanCollide = false
print("Player is on team!")
else
print("Player is not on team!"
end
end
script.Parent.MouseClick:Connect(onClick)
Please embed code, it makes it easier to read. To do so put three backticks (```) and then paste the code. After that put three more backticks to end the code block.