13 is the line
THats the line
Just doing some testing, is the part named ‘cookthing’?
You have an extra comma on steps
Yeah, I have a script that begins the cooking, here
local items = {
["cookthing"] = {
cooksTo = {
name = "EpicPart",
steps = 30,
}
}
}
function objPosition(pos1,pos2,studs)
if pos1.Position.Magnitude - pos2.Position.Magnitude <= studs then
return true
else
return
end
end
while wait(1) do
for _,item in pairs(game.Workspace:GetDescendants()) do
if item.Name ~= "Campfire" and item:IsA("BasePart") then
if objPosition(script.Parent, item, 5) then
local itemCook = item:FindFirstChild("CookValue")
if not itemCook then
local cv = Instance.new("IntValue", item)
cv.Name = "CookValue"
cv.Value = cv.Value + 1
itemCook = cv
else
itemCook.Value = itemCook.Value + 1
end
end
end
end
end
That won’t error.
Well that’s a different result for me unfortunately.
Can you screenshot your studio? What’s the name of the part?
It doesn’t have a CookValue in it??
The other script I posted should make the cookvalue.
Did you check that items[item.Name] exists?
Well the error is self explanatory then, if it prints ‘no’ then there is nothing in items[item.Name] and trying to index it will result in an error
Can you do this before line 14:
print(cv.Value, item.Name)
I just realized it also checks for the baseplate, let me do some things and try to fix it
Script works fine when doing that check, as i stated in my post earlier (https://devforum.roblox.com/t/script-not-properly-adressing-a-value-in-a-table/226844/17)
Code, if you are wondering
local items = {
["cookthing"] = {
cooksTo = {
name = "EpicPart",
steps = 30
}
}
}
while wait() do
for _,item in pairs(game.Workspace:GetDescendants()) do
local cv = item:FindFirstChild("CookValue")
if cv then
if items[item.Name] then
if cv.Value == items[item.Name]['cooksTo']['steps'] then
local cframe = item.CFrame
local superPart = game:GetService("ReplicatedStorage"):FindFirstChild(items[item.Name].cooksTo.name)
local epicpart = superPart:Clone()
epicpart.Anchored = true
epicpart.CFrame = cframe
epicpart.Parent = workspace
item:Destroy()
end
end
end
end
end
I just fixed it, realized it checked for baseplate , and it wasn’t in the table. thanks tho
Please mark the relevant post as the solution so others know that this problem is resolved and no longer requires assistance.