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

Attempt to call a number value????

Asked by 4 years ago

I was trying to script a code that teleports players to a certain area when a timer finishes, and from nowhere, when I call the function minutes() its says: Attempt to call a number value.

Please help me.

local timerREM = game.ReplicatedStorage.Timer_RemoteEvent
local Totaltime = {00, 10}  -- For changing the total time of the timer, change the 1st (minutes) and 2nd (seconds) value --
local minutesval = Totaltime[1]
local secondsval = Totaltime[2]
local totaltime = tostring(minutesval.. ": ".. secondsval)

local function minutes()  -- Important Part
    minutesval = minutesval - 1
    totaltime = tostring(minutesval.. ": ".. secondsval)
    timerREM:FireAllClients(totaltime)
end

local function seconds()
    if minutesval == 0 and secondsval == 0 then
        print("The players are spawning again")
        local players = game.Players:GetChildren()
        local PlayerCharacters = {}
        local spawns = game.Workspace.Spawns

        for i, player in pairs (players) do
            table.insert(PlayerCharacters, #PlayerCharacters + 1, player.Character)
        end

        for i, v in pairs(PlayerCharacters) do
            local desiredSpawn = math.random(1, 12)

            v.HumanoidRootPart.Position = Vector3.new(spawns[desiredSpawn].Position + spawns[desiredSpawn].Size/2)
        end

        totaltime = tostring(Totaltime[1].. ": ".. Totaltime[2])
        minutes = Totaltime[1]
        seconds = Totaltime[2]
    end
    if secondsval == 0 then -- Here is the error -- 
        secondsval = 60
        minutes()
    end
    secondsval = secondsval - 1
    totaltime = tostring(minutesval.. ": ".. secondsval)
    timerREM:FireAllClients(totaltime)
end

while true do
    local times = 0
    while times < 60 do
        times = times + 1
        wait(1)
        seconds()
    end
end

The thing is that when I call the function seconds() the script doesnt says there's an error.

This ocurred to me much times, like when I was trying to tween a GUI's position, and when calling functions.

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You reserved minutes & seconds as functions, on line 31-32 you reallocate their identifiers with numeric array elements: {00, 10}.

The compiler is then instructed to call them as functions later on, hence "Attempt to call a number value".

I suggest you change the variable names on the lines mentioned above; I assume you meant: "minutes/seconds-val"?

0
Thanks it helped bruno13bruno13 78 — 4y
0
Thanks it helped bruno13bruno13 78 — 4y
Ad

Answer this question