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

Cloning script not working?

Asked by 9 years ago

So this is in a game script I am making for a game. For some reason, it only works once in the beginning of the first round, but won't work in the second round.

Output gave me nothing and I have no idea what is the problem. Can someone please help me? Here's the script:

--[[
All of the variables and such are defined. I will only be posting the ones that I suspect are part of this issue.
--]]

local back = game.ServerStorage:WaitForChild("BackUp")
local clone = back:clone()
local time2remove = game.Workspace:WaitForChild("Item")

function Respawn()
    time2remove:destroy()
    wait(0.01)
    clone.Parent = game.Workspace
    clone.Name = "Item"
end

while wait() do
    if NewGameMustStart.Value == true then
        NewGameMustStart.Value = false
        msg.Parent = game.Workspace
        msg.Text = "Welcome!" 
        wait(3)
        msg.Text = "A new game is beginning! Sit tight!"
        wait(3)
        msg.Text = "Game Beginning!"
        wait(2)
        Respawn()
        GameOn.Value = true 
        msg:destroy()
    end
end --- There's more to this script, but I'm only posting the parts that matter in this issue.
0
Plus lua block your code. This is done by press the Blue Icon that says Lua and pasting the code in between the lines that appear alphawolvess 1784 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You never set NewGameMustStart.Value back to true. You set it to false in the beginning, but then at the end of the script, you changed GameOn.Value to true. Since NewGameMustStart.Value is left at false, the condition statement is false and the loop never runs a second time.

0
There's more the code, and there are lines where it does set it back to true. If it didn't, the entire script would be screwed up. CoolJohnnyboy 121 — 9y
Ad

Answer this question