local localmoney = script.Parent.Parent:FindFirstChild('money') function touch(part) if part.Name == ("Acube") then part:Destroy() localmoney.Value = localmoney.Value +5 end end script.Parent.Touched:connect(touch)
Let me help you with this. In my opinion, you should increment the Localmoney first before destroying because the script will be destroyed as well!
Here is the script:
local localmoney = script.Parent.Parent:FindFirstChild('money') function touch(part) if part.Name == ("Acube") then localmoney.Value = localmoney.Value +5 part:Destroy() end end script.Parent.Touched:connect(touch)
Any questions? Leave a comment below! Thanks and I hope this will help you!