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

Why is this Opening Door script not working?

Asked by 10 years ago

Door Script:

if game.Workspace.Game.Value == true then
    if open == false then
        for i = 1,100 do
           DoorB.CFrame  = DoorB.CFrame + Vector3.new(0, 14, 0)
            wait(0.1)
        end
        open = true
    end
end

Countdown Script:

if game.Players.NumPlayers <= 1 then
    script.Parent.Text = "You need 1 more player for the game to begin"
end

if game.Players.NumPlayers >= 2 then
    script.Parent.Text = "Welcome to Dark Zone"
    wait(2)
    script.Parent.Text = "Pick your team"
    wait(2)

    local time = 20 

    for i = 1, 20 do 
        wait(1) 
        time = time - 1
        script.Parent.Text = "You have "..tostring(time).." seconds to pick your team"
    end
    script.Parent.Text = ""

    local time = 10 

    for i = 1, 10 do 
        wait(1) 
        time = time - 1
        script.Parent.Text = "The game will begin in "..tostring(time).." "
    end
        game.Workspace.Game.Value = true
        script.Parent.Text = "Doors opening. Make your way to your bases"
end

I have this thing with a countdown, and when it hits 0 it set of a BoolValue to true and I want when the BoolValue (Game) = true then the door moves up 14 studs in height. How come this isn't work?

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago

It doesn't wait for Game.Value to be true, it just checks whether or not it is whenever the script first runs and then the script stops forever. Solution:

workspace.Game.Changed:connect(function()
    if workspace.Game.Value and not open then
        for i=1,100 do
            DoorB.CFrame=DoorB.CFrame+Vector3.new(0,14,0)
            wait(.1)
        end
        open = true
    end
end)

This tells the Changed event to listen for when workspace.Game.Value changes to true and then runs.

0
testing now NinjoOnline 1146 — 10y
0
the door isnt moving, just standing still?? I'll put in the countdown script NinjoOnline 1146 — 10y
0
that would explain why it's just standing still then. 1waffle1 2908 — 10y
Ad

Answer this question