Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My furnace script is not working it wont destroy ores?

Asked by
tjtorin 172
7 years ago
function destroy()
    game.Workspace.drop:Destroy()
end
game.Workspace.drop.Touched:connect(destroy())

I made sure my ore names are drop and all I thought could be wrong can someone tell me what is wrong with my script?

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Firstly, connection statements take in the function that will execute when the event fires. You called the destroy function inside of the connection line.. don't do that. Just list the function name.

Secondly, workspace.drop is a direct indexation of that exact part. In order to detect the part that hit the dropper, you need to setup a Parameter for the Touched event.

Parameters resemble what is returned from the event. Touched events return the part that touched.

function destroy(hit) --'hit' parameter is now the part that touched!
    if hit.Name == "drop" then --Check the hit's name.
        hit:Destroy()
    end
end

workspace.drop.Touched:connect(destroy)
Ad

Answer this question