local parent = script.Parent.Parent.Name
local item_settings = require(game.workspace.Item_Settings)
local values = item_settings[parent]
while wait(values[2]) do
if script.Parent.Parent.Parent.Name == "Purchased" then
local tycoon = script.Parent.Parent.Parent.Parent
local ore_storage = tycoon.Ore_Storage
local ore = script.Parent:Clone()
local cash = Instance.new("IntValue", ore)
ore.Name = "Ore"
ore.CanCollide = true
ore.Anchored = false
ore.Parent = ore_storage
cash.Name = "Cash"
cash.Value = values[1]
game.Debris:AddItem(ore, 20)
end
end
so basicaly the module is in workspace and im trying to make it where i can put the script in any dropper and not have to do anything to it
the error is in line 4 and values is the nil value parent is useing the name of the model and finds that same name in the module script and its a table with settings for the dropper like drop speed and ore value
Well if we look at line 4
(where you said error is occurring) you will see that we're trying to index a key in a table that is nil. values[2]
This means that the variable values
is nil. You cant index nil objects. Since values
its self is nil we can trace back the problem to the declaration of values
which is on line 3. local values = item_settings[parent]
This here is wrong
parent is using the name of the model and finds that same name in the module script
ROBLOX uses a datatype called a "userdata" for instances such as parts and such. When you're indexing item_settings[parent
, it is looking for a key within the dictionary that has the key for the reference to the userdata parent
and not the name of parent
.
On line 3
which is local values = item_settings[parent]
; replace item_settings[parent]
with item_setings[parent.Name]
so it will look for the string inside of the item_settings with parent
's name instead of using the reference to the userdata.
Sorry i found out what it was its because i had the dropper script in the drop part which i was cloning and using as the ore so i would have to edit all the brick color and stuff and it was running in the ore storage cause i forgot to delete the script in the ore before the ore spawned.