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

How does one go about removing a clone of a part on touch?

I'm very new to roblox studio and this feels like a really dumb question but it's the last part of one of my game mechanics that I need and after going through several different scripts I still don't have an answer. Someone please help...

local debounce = false
local Part = ServerStorage.Iron

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

function onTouch(part) 

local human = part.Parent:findFirstChild("Humanoid") 
if (human ~= nil) and debounce == false then

debounce = true

local player = getPlayer(human) 

if (player == nil) then return end 

script.Parent.IronOre:clone().Parent = player.Backpack 
wait(2)
debounce = false
end
end


script.Parent.Touched:connect(onTouch)

local Part = ServerStorage.Iron
Part:Destroy()
	

I don't really know what's wrong...

3 comments

0

as i see the biggest problem is you placed 1 function into the function

0

2*

0

Wdym??

1 answer

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