foolskarp
(foolskarp)
January 4, 2021, 12:24am
#1
I used a sim shop model from alvinblox and tried to modify it and customize it to my liking, one problem, all of a sudden this started popped up in the output: Attempted to index nil with ‘Name’. Why is this happening?
boxName:GetPropertyChangedSignal(“Value”):Connect(function()
local model = nil
for i, object in pairs(game.Workspace.ItemRoller[“Box”…boxName.Value]:GetChildren()) do
if object:IsA("Model") then
model = object -- Swtting the model variable to the object
end
end
local toolsBought = game.ReplicatedStorage.GetToolsBought:InvokeServer()
for i, tool in pairs(toolsBought) do
if tool == model.Name then --ISSUE HERE
-- Already bought by the player
script.Parent.Text = "Equipped"
else
script.Parent.Text = "Equip"
end
end
end)
it says attempted to index nil with name yet the model clearly exists and does have a name property…?
boeljoet
(boeljoet)
January 4, 2021, 12:29am
#2
you search all the objects in for i, object in pairs(game.Workspace.ItemRoller[“Box”…boxName.Value]:GetChildren()) do
but i dont see what boxName
is
boeljoet
(boeljoet)
January 4, 2021, 12:32am
#4
is the script in the localscript i see in the screen shot?
foolskarp
(foolskarp)
January 4, 2021, 12:33am
#6
or could I just send you the whole model that I used?
boeljoet
(boeljoet)
January 4, 2021, 12:37am
#7
well your issue is at model.Name
so my gues would be that model = object
never happend
try changing this
if object:IsA("Model") then
model = object -- Swtting the model variable to the object
end
to
if object:IsA("Model") then
model = object -- Swtting the model variable to the object
print("switched the model")
end
and if you run this see if the output says “switched the model”
foolskarp
(foolskarp)
January 4, 2021, 12:39am
#9
looked in the output, didnt print anything…
boeljoet
(boeljoet)
January 4, 2021, 12:41am
#10
this can have 2 causes
1: it is searching in the wrong folder
2: there is no “model” in that folder
foolskarp
(foolskarp)
January 4, 2021, 12:42am
#11
OH, I managed to fix it. There was a folder that would display the tool models and for some reason the tools were not anchored, meaning they just fell through the floor and dissappeared which is what caused the issue. I’m so sorry for all the trouble.