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

How do i make the time reset when someone touch a part and his name will display 5 seconds on ui?

Asked by
thifal2 14
2 years ago

Time script/round system

-- Round Variable
local roundLength = 270
local intermissionLength = 15
local InRound = game.ReplicatedStorage.InRound
local LobbySpawn = game.Workspace.LobbyFloor
local BorderPart = game.Workspace.Walls.BorderPart
local Status = game.ReplicatedStorage.Status
local TMF = require(script.TFM)
local reset = game.ReplicatedStorage.Reset

InRound.Changed:Connect(function()
    task.wait(1)
    if InRound.Value == true then
        BorderPart.Transparency = 1
        BorderPart.CanCollide = false
        BorderPart.SurfaceGui.TextLabel.Visible = false
    else
        BorderPart.Transparency = 0.2
        BorderPart.CanCollide = true
        BorderPart.SurfaceGui.TextLabel.Visible = true
        for _, v in pairs(game.Players:GetChildren()) do
            local char = v.Character
            char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
        end
    end
end)




local function roundTimer()
    while wait() do
        for i = intermissionLength, 1, -1 do
            InRound.Value = false
            wait(1)
            Status.Value = "Intermission: ".. i .. " seconds left!"
        end

        for i = roundLength, 1, -1 do
            local convers = TMF:Convert(i, "Default", false)
            InRound.Value = true
            wait(1)
            Status.Value = convers
        end

    end
end

spawn(roundTimer)

the part script

local part = script.Parent
local part2 = game.Workspace.LobbyFloor
local sht = part.ToAddWins
local shp = part.ToAddMoney
local Status = game.ReplicatedStorage.Status
local InRound = game.ReplicatedStorage.InRound
local reset = game.ReplicatedStorage.Reset

part.Touched:Connect(function(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

    for _, players  in pairs(game.Players:GetChildren()) do
        players.Character.HumanoidRootPart.CFrame = part2.CFrame
    end

    reset.Value = true

    player:WaitForChild("leaderstats").Wins.Value += sht.Value
    player:WaitForChild("leaderstats").Cash.Value += shp.Value

end)

when i try to do if the value true it will "intermission" and if the value false it will do "game time" but it doesn't work.

Answer this question