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

Why is this script that 'regens' a model 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:remove()
    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:remove()
    end
end --- There's more to this script, but I'm only posting the parts that matter in this issue.

1 answer

Log in to vote
0
Answered by 9 years ago

First of all, I'd highly recommend not using :remove(), it is deprecated, unstable, and no longer supported. Instead, you should certainly use :Destroy().

Your "msg" probably needs to be created again, since you are removing it. Furthermore, you are attempting to place the clone into the Workspace every round.

I'm not quite understanding time2remove. Could you provide a bit more code that happens before the code you provided, or explain what time2remove's purpose is?

0
Before the code is just a bunch of definitions and variables. And I haven't noticed any issues with the "msg" before. CoolJohnnyboy 121 — 9y
0
Okay, could you explain what you expect to happen and what actually happens? Programmix 285 — 9y
Ad

Answer this question