Skip to content
The Chat Archive
gpt-4-0314· OpenAI WildChat-4.8M (AI2)

I'm working on a fivem script I have table = {['teamA'] = 0, ['teamB'] = 1} I want to…

  1. User

    I'm working on a fivem script I have table = {['teamA'] = 0, ['teamB'] = 1} I want to turn that into the format 0 - 1

  2. Assistant

    You can use the following line of code to concatenate the values and format the text accordingly:

    formattedResult = table['teamA'] .. " - " .. table['teamB']
    

    Now, the formattedResult variable will contain the string "0 - 1".

  3. User

    local formattedScore = table['teamA'] … " - " … table['teamB'] this is giving me an error

  4. Assistant

    My apologies for any confusion. It appears you're using the incorrect concatenation operator. The correct symbol in Lua is ... You should use this code instead:

    local formattedScore = table['teamA'] .. " - " .. table['teamB']
    

    This should fix the error and properly format the score.

  5. User

    Error parsing script @main-volleyball/server/main.lua in resource main-volleyball: @main-volleyball/server/main.lua:19: unexpected symbol near '<\226>' getting this error

  6. Assistant

    It seems the error is related to an unexpected character in your main.lua file. The provided code in the previous response shouldn't cause this specific error. I recommend checking your main.lua file around line 19 for any unexpected or special characters, and remove or correct them.

    In the case that the error still persists after double-checking, please provide the relevant code from your main.lua file around that line for further assistance.

  7. User

    its got to do with the formatted score

  8. Assistant

    I apologize for any confusion. Let's break down the code and check the concatenation again.

    local table = {['teamA'] = 0, ['teamB'] = 1}
    local formattedScore = table['teamA'] .. " - " .. table['teamB']
    print(formattedScore)
    

    This code initializes a table with team scores, concatenates the values with " - ", and prints the formatted score.

    Please ensure you've copied the code correctly, and double-check your main.lua file for any unclosed brackets or other syntax issues that may be causing the error. If the problem persists, please provide more context or additional code snippets from your script for further analysis.