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

How do I add currency when a part gets removed?

Lets say when a part is removed then the script inside that part will add currency to itself.

Like when the parent of the script which is the part , gets removed the script will add the currency to the player.

-- Part getting removed

currency = currency + 1

end

1 comment

0

or you can check if a player touched a part, then the part gets removed, then add currency to the player.

2 answers

✓ Accepted answer
local Workspace = game.Workspace
local part = Workspace.Part

Workspace.ChildRemoved:Connect(function(child)

	if child == part then
	
		currency = currency + 1
	end
end)

ChildRemoved fires when a child of the object is removed and child is the object that got removed

if not workspace:FindFirstChild("Part") then -- checks if its in workspace, if not itll run, make sure this isnt in the part either
	currency = currency + 1
end

1 comment

0

this will only check once

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