Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How add cash when player clicks on brick with ClickDetector?

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

✓ Accepted answer

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)


1 comment

0

How could i be so stupid , Thanks Alot!

This discussion is preserved as it was. New answers, comments, and votes are closed.