Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How do I add currency when a part gets removed?

Asked by 1 year ago
Edited 1 year 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 318 — 1y

2 answers

Log in to vote
0
Answered by
Lazarix9 245 Moderation Voter
1 year 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 1 year 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 — 1y

Answer this question