So i have a furnace for my tycoon -- it works in the sense that it destroys the ores and adds money however the issue comes when i attempt to use 2 different 'droppers'
(just a side note i have 2 droppers, 1 drops an ore Named ore1 and the other ore2
if ore2 goes into the furnace before ore1 ore1 is 'processed' by the furnace and gets destroyed and gives the player money - i would like them to both separately go into the furnace excuse the messy code : P
Furnace Code
function onTouch(hit) if hit.Parent:FindFirstChild("ore1") then local Part1 = game.Workspace:FindFirstChild("ore1") local ore1Value = 25 Part1:Destroy() game.Workspace["Tycoon 1"].DropperMoney.Value = game.Workspace["Tycoon 1"].DropperMoney.Value + ore1Value else if hit.Parent:FindFirstChild("ore2") then local Part2 = game.Workspace:FindFirstChild("ore2") local ore2Value = 50 Part2:Destroy() game.Workspace["Tycoon 1"].DropperMoney.Value = game.Workspace["Tycoon 1"].DropperMoney.Value + ore2Value end end end script.Parent.Touched:Connect(onTouch)
if there is any code you need me to add please tell me (:
I think I see what is happening. So ore2 hits the furnace, and you create a variable "hit" that represents that part. Then on line 3 you get "hit.parent". I am assuming your ore is a child of workspace so hit.parent is the workspace. Because ore1 is at the back of the conveyer and a child of workspace, line 3 detects ore1 and destroys it, then promptly detects ore2 as well getting rid of both of them. To fix this, use
if hit.Name == ("Ore1")
Instead of
if hit.Parent:FindFirstChild("Ore1")