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

This script should send players to the towers and back to the lobby, yet it does not? (FIXED)

Asked by 4 years ago
Edited 4 years ago

Can anyone even know what is wrong with my code? I have checked and have no idea why it is not working. It worked in the past but i modified some of it and its not doing what i want. (Also no errors in the output)

I have changed the code several times yet its still not working, there is a bug with the ROBLOX lua or there is a flaw I don't even know it was there.

This script was supposed to send players from the lobby to 3 towers randomly, when times is finished it sends them back to the lobby, but it does not. Also the status is also not changing. (or really?)

Anyways, I want to give a thousand hugs to that person who managed to fix this.

The script that updates the gui and most importantly, sends the player to the towers and sends them back when the time runs out:

local roundLength = 10
local intermissionLength = 100
local inRound = game.ReplicatedStorage.inRound
local Status = game.ReplicatedStorage.Status

local TowerGenerator = math.random(1,3)
local LobbySpawn = game.Workspace.Lobby.Floor.Center.SpawnLocation

local Normal = game.Workspace.Normal.Ground.Teleporter
local MoltenCave = game.Workspace.MoltenCave.Ground.Teleporter
local LavaFacility = game.Workspace.LavaFacility.Ground.Teleporter

inRound.Changed:Connect(function()
    if inRound.Value == true then
    TowerGenerator = math.random(1,3)
        for _, player in pairs(game.Players:GetChildren())do
            local char = player.Character

                if TowerGenerator == 1 then
            char.HumanoidRootPart.CFrame = Normal.CFrame
              elseif TowerGenerator == 2 then
            char.HumanoidRootPart.CFrame = MoltenCave.CFrame
              else
            char.HumanoidRootPart.CFrame = LavaFacility.CFrame
            end
        end
    else
        for _, player in pairs(game.Players:GetChildren())do
            local char = player.Character
            char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
        end
    end
end)

local function roundTimer()
    while wait() do
        for i = intermissionLength, 1, 0 do
            inRound.Value = false
            wait(1)
            Status.Value = "Lobby"
        end
        for i = roundLength, 1, -1 do
            inRound.Value = true
            wait(1)
            Status.Value = ""..i.."s"
        end
    end
end

spawn(roundTimer)--

And here is the script for the GUI for notifying players the status:

local status = game.ReplicatedStorage.Status
local TimerDisplay = script.Parent.TimerDisplay

status.Changed:Connect(function()
    TimerDisplay.Text = status.Value
end)

Anyways, thank you for reading this, it will make me improve my scripting skills.

0
nevermind i fixed it myself DecalMaker2468 21 — 4y

Answer this question