Having trouble with config files

So im making a script
and get this error

[ 5835672] [b2699_GTAProce] MainThrd/ Creating script environments for Better%20Jail
[ 5835672] [b2699_GTAProce] MainThrd/ Started resource Better%20Jail
[ 5835672] [b2699_GTAProce] MainThrd/
[ 5835687] [b2699_GTAProce] MainThrd/ OnConnectionProgress: Downloading content manifest…
[ 5836172] [b2699_GTAProce] UV loop: httpClient/ Required resources: Better%20Jail
[ 5836172] [b2699_GTAProce] MainThrd/ OnConnectionProgress: Loading content manifest…
[ 5836203] [b2699_GTAProce] MainThrd/ Creating script environments for Better%20Jail
[ 5836219] [b2699_GTAProce] MainThrd/ OnConnectionProgress: Mounted Better%20Jail (1 of 1)
[ 5836219] [b2699_GTAProce] MainThrd/
[ 5836219] [b2699_GTAProce] MainThrd/ _____ _ _____ _ _______
[ 5836219] [b2699_GTAProce] MainThrd/ / | | | / | | | |
[ 5836219] [b2699_GTAProce] MainThrd/ | | __ _ __ __ _ _ | | | | | | __ _ ___ | | ___ __
[ 5836219] [b2699_GTAProce] MainThrd/ | | |
| '
/ | '__| __| | | | |/ _ | / | |/ _ \ / _
[ 5836219] [b2699_GTAProce] MainThrd/ | |__| | | | (
| | | | |
| |
| | (| |/ /| | | () | /
[ 5836219] [b2699_GTAProce] MainThrd/ _|| _,|| _| _||_,/
| ||_/ _|
[ 5836219] [b2699_GTAProce] MainThrd/
[ 5836219] [b2699_GTAProce] MainThrd/ Better Jail V1
[ 5836219] [b2699_GTAProce] MainThrd/
[ 5842187] [b2699_GTAProce] MainThrd/ ^1SCRIPT ERROR: @Better%20Jail/server.lua:17: attempt to index a nil value (upvalue ‘Config’)^7
[ 5842187] [b2699_GTAProce] MainThrd/ ^3> ref^7 (^5@Better%20Jail/server.lua^7:13)
[ 5842187] [b2699_GTAProce] MainThrd/

my server.lua (first lines todo with config, i dont want people stealing my script)

– Load Config
local Config = nil
Citizen.CreateThread(function()
Config = require(“config”)
end)

local jailCooldowns = {}
local jailedPlayers = {}

– /jail command handler
RegisterCommand(“jail”, function(source, args)
– Check if the player has the required permission
if not IsPlayerAceAllowed(source, Config.JailPermissions) then

config.lua

print(“Executing config.lua”)

Config = {}

– Jail permissions

Config.JailPermissions = “staff” – Replace with your desired default jail permissions group

– Jail cooldown

Config.JailCooldown = 120 – Replace with your desired default jail cooldown in seconds

– Jail and release locations

Config.JailLocation = vector3(13, 170, 98) – Replace with your desired default jail location coordinates

Config.ReleaseLocation = vector3(-168, 52, 67) – Replace with your desired default release location coordinates

– Minimum and maximum jail time

Config.MinimumJailTimeMonths = 1 – Replace with your desired minimum jail time in months

Config.MaximumJailTimeMonths = 12 – Replace with your desired maximum jail time in months

return Config – Make sure to return the Config table

fxmanifest.lua

fx_version ‘cerulean’
game ‘gta5’

author ‘Your Name’
description ‘Better Jail V1’
version ‘1.0.0’

shared_scripts {
‘config.lua’
}

client_scripts {
‘client.lua’,
}

server_scripts {
‘server.lua’,
}

Please help, iv had this error and CANNOT fix it

Delete in server.lua get config lines.

local Config = nil
Config = require(“config”)

You have already defined it as shared_script, you can directly access the config variable from server.lua.

1 Like

just so you know, AI will still not generate 100% working code as it likes to dream up things that don’t exist in the context, like in this case the “require config” thing

so if i just remove that line itll work?

also not ai i just had a friend help me but they arnt 100% with lua

Isnt working, if you provide your discord ill dm the whole script

If it’s not a private script, can you just share the server.lua file with code view on this post ? it will be more useful to the community, so that other people can solve their problems

If your script is private, I can reach you via dm for help, after solving the problem, please don’t forget to share the solution here

Hey everyone managed to solve, after i removed the line
“local Config = nil
Config = reqiure(“config”)”
It fixed the error, i got another error but turns out my capitilizations for config werent right in the server.lua (for to capitlize) also quibit could i dm you about a serprate issues? This script is a private script so i do not want to share it here but i will post an example of the fix

"RegisterCommand(Config.CommandNames.blackMarket, function(source, args, user)
TriggerClientEvent(‘chatMessage’, -1, “^6^*Black Market | ^6” … GetPlayerName(source) … “^r”, {128, 128, 128}, table.concat(args, " “))
end, false)”

the config after RegisterCommand needs to be captilized

just provide ur dc