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

:bad argument #3 to 'Text' (string expected, got nil)?

Asked by 5 years ago

i was script in and i got a this error:bad argument #3 to 'Text' (string expected, got nil) the script is:

while true do
    local id = game.ReplicatedStorage.id:InvokeServer()
    if id[0] == 'game_tp' then
        script.Parent.Visible = true
    end
    if id[0] ~= 'game_tp' then
        script.Parent.Visible = false
    end
    wait(0.1)
    script.Parent.dec.Text = id[2]
    script.Parent.mapname.Text = id[1]
end

this is the sever script:

function id()
    return {game.ServerScriptService.game_cmds_Value, game.ServerStorage.guis.map.map_no_id.thegui.mapname.Text, game.ServerStorage.guis.map.map_no_id.thegui.dec.Text}
end
game.ReplicatedStorage.id.OnServerInvoke = id
0
You have to check what server invoke is i think? StateSector 8 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Lua table index starts at 1 not 0 so on line 10 you are trying to assing text to a nil value as the index id[2] does not exist.

You should alos not be calling InvokeServer in a while loop with a 0.1 wait time. Send the data when it is needed to all player and update them when it changes. Constantly calling remote events / functions will overload the network reulting in lag and dropped requests.

Please review your code and how you want it to work.

Lastly you should use else with your if statment as you check if the first is equal. Better still as you are only assigning a boolean value and all comparison operators return a boolean use.

script.Parent.Visible = id[1] == 'game_tp' -- index should be 1 

Hope this helps.

0
Table indices in all programming languages start with 0 simply because it acts as an offset for the rest of the table. This means that (0,10) would actually be 11 values because the 0 is counted. DeceptiveCaster 3761 — 5y
0
Not in Lua User#24403 69 — 5y
Ad

Answer this question