Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why wont it put a count down when you are spawned in the map?

error: 10:26:56.894 - ServerScriptService.Main:41: attempt to perform arithmetic (sub) on nil and number

    local status = game.ReplicatedStorage.Status

local Maps = game.ReplicatedStorage.Maps:GetChildren()

       local Maps = game.ReplicatedStorage.Maps:GetChildren()

while true do for i = 1,10 do status.Value = "Intermission "..10-i wait(1) end

    local Random = math.random(1, #Maps)

local map = Maps[Random]:Clone()
map.Parent = workspace

status.Value = "Todays Challenge Will Be "..map.Name
wait(4)

local players = game.Players:GetChildren()
for i = 1,#players do
	if players[i].Character ~= nil then
                local spawnLocation = math.random(1,#workspace.Teleports:GetChildren())
		                players[i].Character:MoveTo(workspace.Teleports:GetChildren()[spawnLocation].Position)
		                players[i].Character.Parent = workspace
            end
            end

local rounddLength = 20
local canWin = true

if map:FindFirstChild("Obby")then
	map.EndPart.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			canWin = false
			status.Value = hit.Parent.Name.."Has Beaten This Deadly Challenge"
		end
	end)
end

repeat
	roundLength = roundLength -1
	status.Value = "Time Remaining"
	wait(1)
until roundLength == 0 or canWin == false or #workspace.ingame:GetChildren() == 0

wait(3)
map:Destrory()

end

2 comments

0

roundLength is nil and also, It is impossible to perform arithmetic on a nil value.

0

edited my answer

2 answers

You spelt roundLength ad Destroy wrong, you silly goose!

Try this:

local status = game.ReplicatedStorage.Status

local Maps = game.ReplicatedStorage.Maps:GetChildren()

local Maps = game.ReplicatedStorage.Maps:GetChildren()

while true do
    for i = 1, 10 do
        status.Value = "Intermission " .. 10 - i
        wait(1)
    end
    local Random = math.random(1, #Maps)

    local map = Maps[Random]:Clone()
    map.Parent = workspace

    status.Value = "Todays Challenge Will Be " .. map.Name
    wait(4)

    local players = game.Players:GetChildren()
    for i = 1, #players do
        if players[i].Character ~= nil then
            local spawnLocation = math.random(1, #workspace.Teleports:GetChildren())
            players[i].Character:MoveTo(workspace.Teleports:GetChildren()[spawnLocation].Position)
            players[i].Character.Parent = workspace
        end
    end

    local roundLength = 20
    local canWin = true

    if map:FindFirstChild("Obby") then
        map.EndPart.Touched:Connect(
            function(hit)
                if hit.Parent:FindFirstChild("Humanoid") then
                    canWin = false
                    status.Value = hit.Parent.Name .. "Has Beaten This Deadly Challenge"
                end
            end
        )
    end

    repeat
        roundLength = roundLength - 1
        status.Value = "Time Remaining"
        wait(1)
    until roundLength == 0 or canWin == false or #workspace.ingame:GetChildren() == 0

    wait(3)
    map:Destroy()
end


1 comment

0

it better now but it only says time remaining and a error popped up saying Destroy is not a valid model

This discussion is preserved as it was. New answers, comments, and votes are closed.