after using following script im getting " Workspace.NITS.ServerManager.BusGui.KonfiguracjaZajezdni:2: attempt to index nil with ‘Zajezdnia’ - Server - KonfiguracjaZajezdni:2" error.
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
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.