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?
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?
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.