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

Where do I put this clear backpack script within this script?

Asked by 3 years ago

Soooooo, I found a free round Intermission/Round system here's the script

--Each player is placed slightly farther from the last
local m_bIncrementLocations = true
--Teleports all
local m_bTeleportAll = true -- too lazy to work on this

local m_iTimerLength = 10 --Round length in seconds
--Middle time
local m_iBreakTime = 10 --Intermission

Model = script.Parent
ActiveRound = Model.ActiveRound
RoundTime = Model.RoundTime
IntTime = Model.IntermissionTimeLeft

IntTime.Value = m_iBreakTime

function m_fnHandleTimer()
    if (ActiveRound.Value and RoundTime.Value > 0) then
        RoundTime.Value = RoundTime.Value - 1
    end
    if (ActiveRound.Value and RoundTime.Value <= 0) then
        RoundTime.Value = 0
            Model.IntermissionTimeLeft.Value = m_iBreakTime
        ActiveRound.Value = false
        for i, player in ipairs(game.Players:GetChildren()) do
            max = Model.LobbyBricks:GetChildren()
            randomlocation = math.random(1,#max)
            m_fnTeleportTo(max[randomlocation], player, i)
        end
    end
end

ActiveRound.Changed:connect(function(NewValue)
    if (ActiveRound.Value == false) then
        while(Model.IntermissionTimeLeft.Value > 0)do
            wait(1)
            Model.IntermissionTimeLeft.Value = Model.IntermissionTimeLeft.Value - 1
        end
        RoundTime.Value = m_iTimerLength
        ActiveRound.Value = true
        Model.IntermissionTimeLeft.Value = 0
        for i, player in ipairs(game.Players:GetChildren()) do
            max = Model.GameBricks:GetChildren()
            randomlocation = math.random(1,#max)
            m_fnTeleportTo(max[randomlocation], player, i)
        end
    end
end)

function m_fnTeleportTo(Part, player, i)
        if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
            if (m_bIncrementLocations == true) then
                player.Character.HumanoidRootPart.CFrame = Part.CFrame + Vector3.new(0, i * 5, 0)
            else
                player.Character.HumanoidRootPart.CFrame = Part.CFrame
            end
        end
end

function m_fnHandleActiveGame()
    if (ActiveRound.Value == true and RoundTime.Value == m_iTimerLength) then
        for i, player in ipairs(game.Players:GetChildren()) do
            max = Model.GameBricks:GetChildren()
            randomlocation = math.random(1,#max)
            m_fnTeleportTo(max[randomlocation], player, i)

        end
    end
end

--Run every second
while wait(1) do
    m_fnHandleTimer()
    m_fnHandleActiveGame()
end

Don't Get anxious This script is quite simple and what I wanna do is simpler Soo how do I get that Once every round ends that's this script will run

script.Parent.MouseButton1Click:Connect(function() --Click detector
    -- clear tools
    LocalPlayer.Backpack:ClearAllChildren()
    local toolInCharacter = LocalPlayer.Character:FindFirstChildWhichIsA("Tool")
    if toolInCharacter then -- make sure it exists before destroying it
        toolInCharacter:Destroy()

Its a simple script That I made that clears the player backpack so How do I make so that it clears everybody's inventory system before teleporting to the lobby???

1 answer

Log in to vote
0
Answered by 3 years ago

From what it looks like, you should put that script inside of the function m_fnHandleTimer() function, like this:

function m_fnHandleTimer()
        if (ActiveRound.Value and RoundTime.Value > 0) then
            RoundTime.Value = RoundTime.Value - 1
        end
        if (ActiveRound.Value and RoundTime.Value <= 0) then
            RoundTime.Value = 0
                Model.IntermissionTimeLeft.Value = m_iBreakTime
            ActiveRound.Value = false
            for i, player in ipairs(game.Players:GetChildren()) do
                max = Model.LobbyBricks:GetChildren()
                randomlocation = math.random(1,#max)
                m_fnTeleportTo(max[randomlocation], player, i)

    --here's where the other script might go
    --VVVVVVVVVVVVVVVVVVVVVVVVVV

    script.Parent.MouseButton1Click:Connect(function() --Click detector
        -- clear tools
        LocalPlayer.Backpack:ClearAllChildren()
        local toolInCharacter = LocalPlayer.Character:FindFirstChildWhichIsA("Tool")
        if toolInCharacter then -- make sure it exists before destroying it
            toolInCharacter:Destroy()
            end
        end
    end
Ad

Answer this question