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

How add cash when player clicks on brick with ClickDetector?

Asked by 8 years ago

The player that clicks on the brick will award +100 cash doesn't work (ParticleEmitter Works)

function onClicked()

script.Parent.ParticleEmitter.Enabled = true
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 100
            end
wait(5)
script.Parent.ParticleEmitter.Enabled = false

end




 script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
8 years ago

Your problem is, player is not defined, Try using this:

function onClicked(player)

script.Parent.ParticleEmitter.Enabled = true
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        if cashmoney then
            cashmoney.Value = cashmoney.Value + 100
            end
wait(5)
script.Parent.ParticleEmitter.Enabled = false

end




 script.Parent.ClickDetector.MouseClick:connect(onClicked)


0
How could i be so stupid , Thanks Alot! minetrackmania 186 — 8y
Ad

Answer this question