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

:Clone() only works one time, not the second time. Please can someone help? [SOLVED]

Asked by 3 years ago
Edited by JesseSong 3 years ago

This question has been solved by the original poster.

So I am making a final boss battle with waves of robots attacking the player. Once all robots are dead, they have access to two buttons. They must press these two buttons within 15 seconds otherwise the wave will be repeated. To do this, I simply clone the same folder from serverstorage back into the workspace again. However, this doesn't work. Please help!

local debounce = false

local leftbutton = game.Workspace.FinalRoom.ButtonL
local leftlightning = game.Workspace.FinalRoom.LightningL
local rightbutton = game.Workspace.FinalRoom.ButtonR
local rightlightning = game.Workspace.FinalRoom.LightningR

local robotboss1 = game.ServerStorage.RobotBoss1:Clone()
local robot1reattempt = game.ServerStorage.RobotBoss1Attempt2:Clone()
local robotboss2 = game.ServerStorage.RobotBoss2:Clone()
local robotboss3 = game.ServerStorage.RobotBoss3:Clone()
local robotarmy = game.ServerStorage.RobotArmy:Clone()
local fakerobots = game.ServerStorage.FakeRobots:Clone()

game.ServerScriptService.Round1Handler.Disabled = false
game.Workspace.FinalRoom.Barrier:Destroy()

function startround1()
    if debounce == false then
        debounce = true
        game.Workspace.CurrentRound.Value = 1
        game.ServerStorage.FinalRoomBarrier.Parent = game.Workspace
        game.Workspace.DiedBefore.Value = true
        game.Workspace.FinalBossMusic:Play()
        game.Workspace.FinalRoom.Vincent.Animate.Disabled = false
        wait(3)
        game.Workspace.Teleporter:Play()
        robotboss1.Parent = game.Workspace
    end
end

function startround2()
    if script.Round1Deaths.Value == 2 then
        --Open the buttons!
        leftbutton.Head.ProximityPromptL.Enabled = true
        rightbutton.Head.ProximityPromptR.Enabled = true
        leftlightning.LightningLL.Parent = game.ServerStorage
        leftlightning.ButtonBarrier.CanCollide = false
        rightlightning.LightningRR.Parent = game.ServerStorage
        rightlightning.ButtonBarrier.CanCollide = false
        wait(15)
        if game.Workspace.CurrentRound.Left.Value == true and game.Workspace.CurrentRound.Right.Value == true then
            wait(2)
            game.Workspace.CurrentRound.Value = 2
            game.Workspace.CurrentRound.Left.Value = false
            game.Workspace.CurrentRound.Right.Value = false
            game.ServerScriptService.Round2Handler.Disabled = false
            game.Workspace.FinalRoom.Light1.Light.LightPart.Beam.Attachment1 = game.Workspace.FinalRoom.Light1.Light.LightPart.End2
            game.Workspace.TurningLights:Play()
            wait(3)
            --RESET BUTTONS
            leftbutton.Head.ProximityPromptL.Enabled = false
            rightbutton.Head.ProximityPromptR.Enabled = false
            game.ServerStorage:WaitForChild("LightningLL").Parent = leftlightning
            leftlightning.ButtonBarrier.CanCollide = true
            game.ServerStorage:WaitForChild("LightningRR").Parent = rightlightning
            rightlightning.ButtonBarrier.CanCollide = true
            --
            game.Workspace.Teleporter:Play()
            robotboss2.Parent = game.Workspace
        else
        --Too late! Restart the round
        leftbutton.Head.ProximityPromptL.Enabled = false
        rightbutton.Head.ProximityPromptR.Enabled = false
        game.ServerStorage:WaitForChild("LightningLL").Parent = leftlightning
        leftlightning.ButtonBarrier.CanCollide = true
        game.ServerStorage:WaitForChild("LightningRR").Parent = rightlightning
        rightlightning.ButtonBarrier.CanCollide = true
        script.Round1Deaths.Value = 0
        wait(1)
        game.Workspace.Teleporter:Play()
            robotboss1.Parent = game.Workspace
        end
    end
end

This is a sample of one of the functions. robot1reattempt is the backup option because it is the same as robotboss1 but a different folder which works. However, this is not good enough as this breaks when it tries to clone again as well.

0
Nevermind, I figured it out myself iiPizzaCraver 71 — 3y
0
Yeah remember, you have to parent the thing you wanted it to clone. JesseSong 3916 — 3y
0
No that wasnt the reason, turns out I didnt need to refer to "robotboss1". I just wrote game.ServerStorage.RobotBoss1:Clone(game.Workspace) whenever I needed to use it iiPizzaCraver 71 — 3y

Answer this question