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

:9: attempt to call a number value. Once again confused?

-- Do not Change
local place = game.GameId
-- Settings
local laglevel = "unknown" -- Default Lag Value
local wait = 1 -- Wait time for lag.
-- Lag Finder
print("Game: "..place)
local one = elapsedTime()
wait()
local two = elapsedTime()
local final = two - one
print(final)
-- Lag Estimator
if final > 0.03 then
laglevel = "Tiny Lag"
else
if final > 0.06 then
laglevel = "Small Lag"
else
if final > 0.09 then
laglevel = "Medium Small Lag"
else
if final > 0.12 then
laglevel = "Medium Lag"
end
end
end
end
print(laglevel)
-- Auto Game Switcher
if final > 0.09 then
print("Lag level too high, switching servers...")
-- Switch Server script here
print("This will be replaced with the switch servers script.")
-- to here.
else
print("Lag level is fine.")
end

On line 9, it says attempt to call a number value. Why?

4 comments

0

We need your whole script, because on Line 9 on this code it says "wait()", please provide your whole code, as the error does not match.

0

this is my whole code

0

on line 5 set "wait" to a number, so when you do wait() your calling a number

0

Do you mean a real phone number or what

1 answer

✓ Accepted answer

Oh, you're variable on line 5, you have it as 1. You cannot use built-in functions as variables, try changing line 5 to waitTIme.

Because this is what is happening.

The game thinks the variable wait, which is equal to 1, is a variable and not a function. So, how the game reads it as is 1(). It also reads it as wait(), which will wait 0.03 seconds. So it is confused.

To fix this, change line 5 to a different name, and not a keyword built-in function.

-- Do not Change
local place = game.GameId
-- Settings
local laglevel = "unknown" -- Default Lag Value
local waitTime = 1 -- Wait time for lag.
-- Lag Finder
print("Game: "..place)
local one = elapsedTime()
wait() --// If you want to change how long it waits, you would do wait(AmountYouWant), and it will wait that amount in seconds.

That is how the top of your code should look like.

Hope this helped! If this worked, let me know by selecting this as an answer!

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