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

Why dose this script break and doesn't destroy the tools?

Asked by 3 years ago

So the script is for a upcoming game but the script broke? and alot of it doesn't work? (What I mean by breaks it doesn't work as intended and just breaks)

local lobbyLocation = game.Workspace.Lobby.Position + Vector3.new(0,3,0)
local gameLocation = game.Workspace.Main.Position + Vector3.new(0,3,0)
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local TimeEvent = ReplicatedStorage:WaitForChild('TimeEvent')
--Gameplay Event
local function playgame()
    local TimeTotal = 10 --Amount
    local TimerText = 'Remaining Time: ' --The Lable Text
    while TimeTotal > 0 do
        TimeEvent:FireAllClients(TimerText, TimeTotal)
        wait(1)
        TimeTotal -= 1
    end
end

--Lobby Event
local function lobbyTime()
    local TimeTotal = 10 --Amount
    local TimerText = 'Intermission: ' --The Lable Text
    while TimeTotal > 0 do
        TimeEvent:FireAllClients(TimerText, TimeTotal)
        wait(1)
        TimeTotal -= 1
    end
end

local function resetplr()
    for _, player in pairs(game.Players:GetChildren()) do
        player.Character.HumanoidRootPart.CFrame = CFrame.new(lobbyLocation)

        for toolNumber,tool in ipairs(game:GetService("Players").Backpack:GetChildren()) do
            local toolb = tool:destroy()
            toolb.Parent = player.Backpack
        end 
    end
end
local function gameplr()
    for _, player in ipairs(game.Players:GetChildren()) do

        player.Character.HumanoidRootPart.CFrame = CFrame.new(gameLocation)

        for toolNumber,tool in ipairs(game:GetService("ServerStorage").Items:GetChildren()) do
            local toolC = tool:Clone()
            toolC.Parent = player.Backpack
        end
    end 
end

while true do
    resetplr()
    lobbyTime()
    playgame()
    gameplr()
end
0
explain when it errors, what errors, and what are you confused on? Antelear 185 — 3y

Answer this question