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 5 years ago
Edited 5 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.

1-- Part getting removed
2 
3currency = currency + 1
4 
5end
0
or you can check if a player touched a part, then the part gets removed, then add currency to the player. 0msh 333 — 5y

2 answers

Log in to vote
0
Answered by
Lazarix9 245 Moderation Voter
5 years ago
01local Workspace = game.Workspace
02local part = Workspace.Part
03 
04Workspace.ChildRemoved:Connect(function(child)
05 
06    if child == part then
07 
08        currency = currency + 1
09    end
10end)

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
5 years ago
1if not workspace:FindFirstChild("Part") then -- checks if its in workspace, if not itll run, make sure this isnt in the part either
2    currency = currency + 1
3end
0
this will only check once Lazarix9 245 — 5y

Answer this question