I have tried literally anything. All help appreciated

after using following script im getting " Workspace.NITS.ServerManager.BusGui.KonfiguracjaZajezdni:2: attempt to index nil with ‘Zajezdnia’ - Server - KonfiguracjaZajezdni:2" error.

pojazd = script.Parent.Vehicle.Value
wyborzajezdni = pojazd.Zajezdnia

if wyborzajezdni.Value == “PKS” then
local mod = game.Workspace.NITS.PKS:Clone()
mod.Parent = script.Parent.SIP.Ekran.kurs
elseif wyborzajezdni.Value == “Stalowa12m” then
local mod = game.Workspace.NITS.Stalowa12m:Clone()
mod.Parent = script.Parent.SIP.Ekran.kurs
elseif wyborzajezdni.Value == “Stalowa18m” then
local mod = game.Workspace.NITS.Stalowa18m:Clone()
mod.Parent = script.Parent.SIP.Ekran.kurs
elseif wyborzajezdni.Value == “Stalowa10m” then
local mod = game.Workspace.NITS.Stalowa10m:Clone()
mod.Parent = script.Parent.SIP.Ekran.kurs
elseif wyborzajezdni.Value == “StalowaZABYTKI” then
local mod = game.Workspace.NITS.Stalowa12m:Clone()
mod.Parent = script.Parent.SIP.Ekran.kurs
elseif wyborzajezdni.Value == “Admin” then
local mod = game.Workspace.NITS.All:Clone()
mod.Parent = script.Parent.SIP.Ekran.kurs
else
script.Parent.SIP.Ekran.Menu.LocalScript:Destroy()
script.Parent.SIP.Ekran.awaria.Visible = true
end

1 Like

Your error here is “pojazd” which is nil apparently. What is it supposed to be?

1 Like

These are really bad names for variables. When naming variables, try and make it at least somewhat related to what its storing.

1 Like

“Pojazd” is value that have set vehicle that user is driving. This value helps with configuring driving gui modifications and vehicle scripts.

1 Like

“pojazd” is “vehicle” on polish. “wyborzajezdni” is value that selects spawner where vehicle will spawn, so that’s why its name is “garage” in polish

1 Like

Then if it is nil, try to set it through the script. you could also do something like Value = Value or Instance.new()

Do not use languages other than English for writing code, as this can easily create confusion. Especially if you’re making your model public, searching for help, or the game is made by multiple developers. I tried decoding your code in order to make the lives of other people here easier:

--Situations where garage.Value ~= val for NITS:FindFirstChild(val)
local edgeCases = {
	StalowaZABYTKI = "Stalowa12m",
	Admin = "All"
}

--Better naming for variables
local BusGui = script.Parent
local Vehicle = BusGui.Vehicle.Value
local Garage = Vehicle.Zajezdnia

local val = Garage.Value
local mod = workspace.NITS:FindFirstChild(edgeCases[val] or val)

local Screen = BusGui.SIP.Ekran
--Edge case if val doesn't exist in NITS
if not mod then
	Screen.Menu.LocalScript:Destroy()
	Screen.awaria.Visible = true
	return 
end

--Normal case
mod:Clone().Parent = Screen.kurs

The reason the error occurs is because BusGui.Vehicle.Value is nil when the script starts.

1 Like