0
votes

I have a Roblox Game in this game the time changes using the code on the Roblox Developer site(robloxdev.com) I have been making a door with two unions called "open" and "closed". I want the door to be open between 10 in the morning and 5 in the evening. However the door won't open and it's not even bringing up the print open/close when it is the right time.

This is my current code Note: The script is in the same model (called: Door) as the two unions.

while true do
   if game.Lighting.ClockTime > 10 and game.Lighting.ClockTime < 17 then
        --Open the door
        print("open")
        script.Parent.Closed.Transparency = 1
        script.Parent.Closed.CanCollide = false

        script.Parent.Open.Transparency = 0
        script.Parent.Open.CanCollide = true
    else
        --Close the door
        print("close")
        script.Parent.Closed.Transparency = 0
        script.Parent.Closed.CanCollide = true

        script.Parent.Open.Transparency = 1
        script.Parent.Open.CanCollide = false
    end
end

Thank's for any help.

1
I may have missed it, but whats the issue you are looking for assistance with? is the door not doing what you expect? is the whole game seeming to freeze up? - Nifim
sorry I never said that the door won't open, thanks for pointing it out - Crann Moroney
You might also need to add a wait() inside the while true loop but outside the if statement. - Taazar
Yes I said I was using the Roblox Code for changing the time which is DEFINITELY working. - Crann Moroney

1 Answers

1
votes

You should add wait inside the while loop.

while true do
   if game.Lighting.ClockTime > 10 and game.Lighting.ClockTime < 17 then
        --Open the door
        print("open")
        script.Parent.Closed.Transparency = 1
        script.Parent.Closed.CanCollide = false

        script.Parent.Open.Transparency = 0
        script.Parent.Open.CanCollide = true
    else
        --Close the door
        print("close")
        script.Parent.Closed.Transparency = 0
        script.Parent.Closed.CanCollide = true

        script.Parent.Open.Transparency = 1
        script.Parent.Open.CanCollide = false
    end
    wait(1) -- change this to whatever you want
end