Skip to content

Commit d540e95

Browse files
authored
chest-destroy-function (#1259)
## Changes Removed code discrepancy, in the for loop, between documentation and script from the project. Fixed Destroy function to remove the model correctly. ## Checks By submitting your pull request for review, you agree to the following: - [X] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses. - [X] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses. - [X] To the best of my knowledge, all proposed changes are accurate.
1 parent c444e18 commit d540e95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/en-us/tutorials/fundamentals/coding-6/create-with-module-scripts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ So the player can open a chest, create a function in **TreasureManager** that aw
332332
local playerTreasure = getPlayerTreasure(whichCharacter)
333333
playerKeys.Value = playerKeys.Value - chestPickCost
334334
playerTreasure.Value = playerTreasure.Value + chestReward
335-
chestPart:Destroy()
335+
chestPart.Parent:Destroy()
336336
end
337337
```
338338

@@ -479,7 +479,7 @@ end
479479

480480
-- Binds every chest part to the touch function so it works on all parts
481481
for chestIndex = 1, #chestsArray do
482-
local chestPart = chestsArray[chestIndex]
482+
local chestPart = chestsArray[chestIndex]:WaitForChild("Collider")
483483
chestPart.Touched:Connect(function(otherPart)
484484
partTouched(otherPart, chestPart)
485485
end)

0 commit comments

Comments
 (0)