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)
✓ ANSWER ACCEPTED
Why wont this transfer values?
1 answer
✓ Accepted answer
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!
2 comments
0
thanks for the help but it didnt quite work in the console it errors and says Workspace.block eater.Script line 1 attempt to index global 'money' (a nil value)
0
then you wait until it appears. Use :WaitForChild("money") instead of :FindFirstChild("money")
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
halp
cri