I am a rookie at Lua and Roblox Studio in general. I am attempting an easy and reasonably simple tutorial on how to make a pretty good looking tycoon game. In my "Core" script, I am attempting to make it so when you press a button, a dropper appears, or whatever the StringValue has assigned it to (it is inside the button model). Here is the core script:
local tycoon = script.Parent.Parent
local mainItems = tycoon:FindFirstChild("MainItems")
local values = tycoon:FindFirstChild("Values")
local buttons = tycoon:FindFirstChild("Buttons")
local purchasedItems = tycoon:FindFirstChild("PurchasedItems")
local objects = {}
mainItems.OwnerDoor.Door.Touched:Connect(function(hit)
if values.OwnerValue.Value == nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player:FindFirstChild("HasTycoon").Value == false then
values.OwnerValue.Value = player
mainItems.OwnerDoor.Title.SurfaceGui.TextLabel.Text = tostring(values.OwnerValue.Value).."'s Tycoon"
end
end
end
end)
if buttons then
for i, v in pairs(buttons:GetChildren()) do
spawn(function()
if v:FindFirstChild("Button") then
local newObject = purchasedItems:FindFirstChild(v.Object.Value)
if newObject ~= nil then
objects[newObject.Name] = newObject:Clone()
newObject:Destroy()
else
v:Destroy()
end
if v:FindFirstChild("Dependency") then
v.Button.Transparency = 1
v.Button.CanCollide = false
v.Button.BillboardGui.Enabled = false
coroutine.resume(coroutine.create(function()
if purchasedItems:WaitForChild(v.Dependency.Value) then
v.Button.Transparency = 0
v.Button.CanCollide = true
v.Button.BillboardGui.Enabled = true
end
end))
end
v.Button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if values.OwnerValue.Value == player then
if v.Button.CanCollide == true then
if player:FindFirstChild("leaderstats").Cash.Value >= v.Price.Value then
player.leaderstats.Cash.Value -= v.Price.Value
objects[v.Object.Value].Parent = purchasedItems
v:Destroy()
end
end
end
end
end)
end
end)
end
end
It is a pretty long script, but my error occurs on line 42. In my output, the error reads:
Infinite yield possible on 'Workspace.Tycoons.Tycoon.PurchasedItems:WaitForChild("Dropper")'.
Dropper
, but was unable to find it. I didn't seeDropper
when I searched the Roblox Lua documentation & I didn't see it defined in the code you posted. Where are you intending it to findDropper
? Is it a script you made? \$\endgroup\$