Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this transfer values?

Asked by 8 years ago
01local localmoney = script.Parent.Parent:FindFirstChild('money')
02function touch(part)
03 
04    if part.Name == ("Acube") then
05        part:Destroy()
06        localmoney.Value = localmoney.Value +5
07 
08    end
09    end
10 
11script.Parent.Touched:connect(touch)
0
halp macabe55101 38 — 8y
0
cri macabe55101 38 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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:

01local localmoney = script.Parent.Parent:FindFirstChild('money')
02function touch(part)
03 
04    if part.Name == ("Acube") then
05        localmoney.Value = localmoney.Value +5
06    part:Destroy()
07    end
08    end
09 
10script.Parent.Touched:connect(touch)

Any questions? Leave a comment below! Thanks and I hope this will help you!

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) macabe55101 38 — 8y
0
then you wait until it appears. Use :WaitForChild("money") instead of :FindFirstChild("money") starlebVerse 685 — 8y
Ad

Answer this question