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

How do I add currency when a part gets removed?

Asked by 4 years ago
Edited 4 years ago

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
0
or you can check if a player touched a part, then the part gets removed, then add currency to the player. 0msh 333 — 4y

2 answers

Log in to vote
0
Answered by
Lazarix9 245 Moderation Voter
4 years ago
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

Ad
Log in to vote
0
Answered by
0_2k 496 Moderation Voter
4 years ago
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
0
this will only check once Lazarix9 245 — 4y

Answer this question