Button that can open a door based on if your in a group

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    Okay so i am trying to make a button that opens a door in 5 seconds and after that closes it.

  2. What is the issue? Include screenshots / videos if possible!
    It need to be a “group” button, so the button can only be used by those that are in the group, and if they are in the group the door will open and if not it cannot be opened.

Notes:
Script so far

Button

Door:

Whats the actual issue here?
You listed the functionality as the issue.

If you were planning to have it open for others if someone who is that rank or higher presses it then you might want to change it to a server script.

if not then please elaborate so we can help you more with this.

What im trying to do here is that a personell of the group is a border controller, who has to open the door for people trying to pass through the border, and i want it so that group people and only group people can press that button. But the script i wrote does not work, it has to turn invisible and can collide set to false. thats what im struggling with

Try using the mouse click function in the server side, and create a client sided remote function that opens the door.

Uhh, well is it to late to say that im not that experienced at scripting. Could you give an example? :slight_smile:

local door =  --put the location of the door here
local button =  --put the location of the button here
local click_detector =  --put the location of the ClickDetector here

button[click_detector.Name].MouseClick:Connect(function(plr)
	if plr:GetRankInGroup(group id here) >= 10 then
		door.CanCollide = false
		door.Transparency = .5
		wait(5)
		door.CanCollide = true
		door.Transparency = 0
	else
		--you can do something here if you want
	end
end)

Make sure this is a Script, not a LocalScript.

1 Like
-- this is a local script

button.Clicked:Connect(function()
game.ReplicatedStorage.NAME:FireServer() -- change NAME to the name of the remote event object that you put in replicated storage.
end)

The remote event then should send signal to a regular script that then should do its job ( I believe )

-- this is regular script

game.ReplicatedStorage.NAME.OnServerEvent:Connect(function() -- same name of remote event
-- blah blah blah, whatever you need to do you put here, in your case it would be
door.Transparency = ...
door.CanCollide = false
wait(5)
door.Transperency = ...
doort.CanCollide = true
-- be aware that there is no cooldown on button, because I was too lazy to do that.
-- Also not sure if this entire thing will work, but in my experience it does.

So in perspective, you use local script to get LocalPlayer group rank I think, then if the requirement is meant, the remote event is being fire, which then makes door work as you please.

Once again, it is really raw and will not work in the exact form as I gave you, you have to make some edits yourself. Also would recommend reading documentation about remote events.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.