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 7 years ago
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)

0
halp macabe55101 38 — 7y
0
cri macabe55101 38 — 7y

1 answer

Log in to vote
0
Answered by 7 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:

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!

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

Answer this question