How to make a flood escape interactive button?

I am trying to make a flood escape game as a beginner project to practice my scripting abilities.

I cannot find any tutorials for this, but here is what I am wanting to achieve:
I want to make a door that opens as soon as the players touch all the green buttons. If you have played those Flood Escape games, you’ll know what I mean. I want to keep it as simple as touching 5 parts to open a door. By open, I mean door:Destroy() gets executed as soon as all the buttons are touched.

Side note: I have about as much scripting knowledge as someone who has watched a full playlist of videos like “Beginner’s Scripting Tutorial”

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

1 Like

What should I do if I have multiple rooms?

Thanks for the help! Do you think there is a simpler approach? I thought about doing something where I place all the buttons in one room into a group (or model) and once all the buttons in that group are touched, the door gets destroyed.

1 Like

@whitezane444

Here is an easier way

Here is an easier way:
Note: May look hard at beginning, but easier once you read instructions.

  1. Make a new folder for each room.
  2. Place each button in the folder.
  3. Make 2 Attributes in the folder (RequiredButtons, ButtonsHit: Both NumberValues)
    3.5. Keep all at 0
  4. Place this server script in every button:
Server Script
local this_buttonGotHit = false
local CompRoom = false
local RoomFolder = script.Parent.Parent -- Choose where the current room folder should be.

local door = RoomFolder.Door -- Choose

local registeredPart = false
if registeredPart == false then
	registeredPart = true
	wait(0.1)
	RoomFolder:SetAttribute("RequiredButtons",RoomFolder:GetAttribute("RequiredButtons") + 1)
end

script.Parent.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		if RoomFolder:GetAttribute("ButtonsHit") >= RoomFolder:GetAttribute("RequiredButtons") and CompRoom == false then
			CompRoom = true
			door:Destroy()
		end
		if this_buttonGotHit == false then
			this_buttonGotHit = true
			wait(0.1)
			script.Parent.BrickColor = BrickColor.Red()
			if RoomFolder:GetAttribute("ButtonsHit") < RoomFolder:GetAttribute("RequiredButtons") then
				RoomFolder:SetAttribute("ButtonsHit",RoomFolder:GetAttribute("ButtonsHit") + 1)
			end	
		end
	end
end)
  1. Configure the script above. (One time thing)
  2. Good To Go!

Here is a kit I made for this (kit has more features):
Kit - Roblox
Attributes should already be added to the folder.
If there are no attributes in the folder, then you have to add them. (Read step 3, 3.5)

1 Like

Thank you so much! I’m a beginner scripter and I am learning how to script. I’ll make sure to study what the script does and stuff, I don’t want to just take a free model. I managed to make my own by looking at your free model. You have no idea how useful this post and kit was. Thank you!

1 Like