I implimented the changes but now its saying line 8 is indexing nil with waitforchild agein. btw this is my code now
local Values = script.Parent.Parent.Parent.Values
repeat
wait()
until Values.OwnerValue
while wait(3) do
if Values.OwnerValue.Value:WaitForChild(“leaderstats”).Peanuts.Value >= 1 then
local reference = script.Parent:WaitForChild(“reference”)
local drop = game:GetService(“ServerStorage”).PeanutDrop:Clone()
drop.Parent = game.Workspace
drop.Position = reference.Position
drop.Name = “drop”
local pbamount = Instance.new("NumberValue")
pbamount.Parent = drop
pbamount.Name = "pbAmount"
pbamount.Value = 1
Values.OwnerValue.Value:WaitForChild("leaderstats").Peanuts.Value -= 1
end
end