Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Tycoon furnace not working properly all ores getting destroyed how to fix?

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 (:

6 comments

0

Aren't they supposed to be destroyed? Isn't that the point of a furnace in a dropper tycoon?

0

hmm lemme try n' explain so ore1 is at the start of the conveyor and ore2 is at the furnace, when ore2 is destroyed the same happens to ore1 while it's at the start of the conveyor

0

Ah. You can change the names of the ores if they both have the same name.

0

i have 2 droppers 1 drops an ore Named ore1 and the other ore2

0

doesn't it need to be "elseif"? not else and then if

0

the 1st ore still dies

1 answer

✓ Accepted answer

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")

2 comments

0

You should also fix line 11 so that all Ore2 parts are not destroyed

0

Thanks (:

This discussion is preserved as it was. New answers, comments, and votes are closed.