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

I'm trying to make a door appear every 30 seconds how do I fix this?

Asked by 3 years ago

So I'm making a elevator game and im trying to have an elevator door appear every 30 seconds, the floors end every 30 seconds but for some reason the timing with the door is off, ill show a portion of the floor script which is fine, then the door script.

-- this script is fine
elseif floor == 4 then
        wait(2)
        ooo = game.ServerStorage.FLOORS.BOSSFIGHT1:Clone()
        ooo.Parent = game.Workspace
        ppp = game.ServerStorage.Weapons.sword:Clone()
        ppp.Parent = game.Workspace
        wait(30)
        ooo:Destroy()
        ppp:Destroy()
    end
end

here is the one that i cant fix.

while true do
    local dor = game.ServerStorage.door:Clone()
    wait(30)
    dor.Parent = game.Workspace
    wait(2)
    dor:Destroy()
end

Ive tried messing with the door script and i dont want to add it to my floor script because then i have to write more code

0
Try putting the local dor = game.ServerStorage.door:Clone() outside of the looped function, make sure to remove the 'local' as it's outside of the function HauntedDestroyer 106 — 3y
0
ok pokemon9master29 6 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Here's a complete fix.

    local dor = game.ServerStorage.door:Clone()
    wait(30)
    dor.Parent = game.Workspace
while true do
--This will make it disappear again.
    wait(30) --Or, you can change it to 2.
    dor.Transparency = 1
dor.CanCollide = false

wait(30) --Change it to 2 if you want to. 
--This will make it appear again.
 dor.Transparency = 0
dor.CanCollide = true
end

Hopefully this will work. If there is scripts in the door, do:

    local dor = game.ServerStorage.door:Clone()
    wait(30)
--Copy and paste the line below if you have more scripts
                              dor.ScriptName.Disabled = true
    dor.Parent = game.Workspace
while true do
--This will make it disappear again.
    wait(30) --Or, you can change it to 2.
    dor.Transparency = 1
dor.CanCollide = false
wait(30) --Change it to 2 if you want to. 
--This will make it appear again.
 dor.Transparency = 0
--Copy and paste the line below if you have more scripts
                              dor.ScriptName.Disabled = false
dor.CanCollide = true

My best answer, I'm not sure if it will work, not tested.

Ad

Answer this question