Hello!
Im currently working on a unboxing system which have a randomize value. When the value was recieved. It will work on a randomization. Every thing seems to work fine. But when I test it it appears this error on my dev console:
local thingy = script.Parent.Parent.Parent:WaitForChild("AddStuff")
local alltables = {}
if casename == "Extreme Case" then
local repeater = 70
local gatlingpea = 20
local cherrybomb = 10
for i=1,repeater do
table.insert(alltables,game.ReplicatedStorage:WaitForChild("ItemsAll"):FindFirstChild("Repeater"))
end
for i=1,gatlingpea do
table.insert(alltables,game.ReplicatedStorage:WaitForChild("ItemsAll"):FindFirstChild("Gatlingpea"))
end
for i=1,cherrybomb do
table.insert(alltables,game.ReplicatedStorage:WaitForChild("ItemsAll"):FindFirstChild("Cherrybomb"))
end
end
local selected = alltables[math.random(1,#alltables)]
--[[line 20--]] script.Parent.Parent.Parent.AddStuff.Stuff.Value = game.ReplicatedStorage:WaitForChild("ItemsAll"):FindFirstChild(selected.Name)
script.Parent.Parent.Parent.AddStuff.Remove.Value = false
script.Parent.Parent.Parent.AddStuff.Value = true
local clonedselected = selected:Clone()
clonedselected.Parent = script.Parent
script.Parent.Parent.Parent.RewardShower:Fire(selected.Name)
It says that the error happens on line 20 and i dont know what is the problem with it.
Whatever Insrance youre calling doesnt seem to have a Value property, seems like an ancestry issue
note: Is there any other way you can organize your script instead of doing script.Parent.Parent.Parent.Parent.Parent, its not the most effective or understandable method, its not the greatest practice either
Only ObjectValue instances can have their “Value” property set with a value which is in fact an instance/object, the other primitive value instances such as “IntValue” or NumberValue" can only store integer values and number values respectively for example.
local rs = game:GetService("ReplicatedStorage")
local itemsAll = rs:WaitForChild("ItemsAll")
local repeater = itemsAll:WaitForChild("Repeater")
local gatling = itemsAll:WaitForChild("Gatlingpea")
local cherry = itemsAll:WaitForChild("Cherrybomb")
local thingy = script.Parent.Parent.Parent:WaitForChild("AddStuff") --try to make this cleaner
local alltables = {}
local casename = "Extreme Case" --change this i just added it to remove the blue line warning
if casename == "Extreme Case" then
local repeater = 70
local gatlingpea = 20
local cherrybomb = 10
for i=1, repeater do
table.insert(alltables, repeater)
end
for i=1, gatlingpea do
table.insert(alltables, gatling)
end
for i=1, cherrybomb do
table.insert(alltables, cherry)
end
end
local selected = alltables[math.random(1, #alltables)]
--[[line 20--]] script.Parent.Parent.Parent.AddStuff.Stuff.Value = itemsAll:FindFirstChild(selected.Name) --make the reference of the bit before the "=" cleaner
script.Parent.Parent.Parent.AddStuff.Remove.Value = false --make this reference and all the ones below it cleaner
script.Parent.Parent.Parent.AddStuff.Value = true
local clonedselected = selected:Clone()
clonedselected.Parent = script.Parent
script.Parent.Parent.Parent.RewardShower:Fire(selected.Name)
This isn’t a fix but I’ve cleaned up what I could.