How to make a door that opens after five minutes

bassicly the title

Put this script under the door

local door = script.Parent
local timesRan = 0

while wait(1) do
timesRan = timesRan + 1

if timesRan == 300 then
	door.CanCollide = true
	door.Transparency = 0.5
end

end

1 Like

Why not?

task.wait(300)
door.CanCollide = true
door.Transparency = 0.5
1 Like

Ill do you one better

task.wait(5*60)
door.CanCollide = true
door.Transparency = 0.5

this way you dont even need a calculator

1 Like

Try this.

local CurrentTime = Tick()
local TimeToOpen = CurrentTime + 300

Repeat
 wait(1) 
until Tick() >= TimeToOpen

“ open door 🚪”

2 Likes
local Door = script.Parent
local isOpen = false


while true do
	if isOpen == false then
		Door.Transparency = 0.5
		Door.CanCollide = false
		isOpen = true
	else
		Door.Transparency = 0
		Door.CanCollide = true
		isOpen = false
	end
	task.wait(2)
end

(Closes too)

1 Like

Why, you just unnecesarrily complicated it

It’s a different way of doing it.
Also if you wanted to, you could make it open at the same time in all servers.
(Which the person might need.)

If the solution if not found yet. Don’t keep repeating the same code in slightly less lines. :penguin:

1 Like

im making this door for a bossfight and i want you to have to survive for 5minutes not kill the boss so how would i make the timer only start counting down once the player enters the arena?

also how would i make the timer reset when the player dies?

Well if you are teleporting the players inside the arena then you can make the timer start there else detect when the player enters the door. To reset the timer when the player dies use the humanoid.Died event and then set the time to the initial one.

If there are more players in the arena the solution to reset the timer would not be really suitable and so you would want to reset it when all the players die and you can achieve it by doing something like the following:

local playersInArena = {} -- insert all the players instances in the table

for i, player in pairs(playersInArena) do
   player.Character.Humanoid.Died:Connect(function() 
        table.remove(playersInArena, table.find(playersInArena, player) -- remove the dead player from the table

        if #playersInArena == 0 then
            -- reset the timer here because the length of the array is 0 which means there are no more players alive
        end
    end
end
1 Like

the player doesnt spawn in the arena but its also a single player game