#Click on screen add 1

18 messages · Page 1 of 1 (latest)

vast magnet
#

When you click on the screen there should be an integer (money) that should go up by one. Please help me.

shy sail
#

Create a Text/Image Button and a script
Make the Button as you want and start working on the script

You can use MouseButtton1Click even to run a function when the player press the button

Assuming you already have a data script, you can change the value of cash (money) by clicking on the button and adding 1 to the value

Here is an example:

local plr = script.Parent.Parent.Parent.Parent
--First we get the player

script.Parent.MouseButton1Click:Connect(function()
    --When player click the button, it will run the function
    plr.leaderstats.Money.Value += 1
    --Player's Money got changed
end)

If you have any question you can ask

vast magnet
#

Is there a way to do it without a button?

shy sail
#

No

#

Or at least not a easy way

regal nova
#

yes

#

using UserInputService

shy sail
#

"click on the screen"

regal nova
#

yes

#

he doesn't said textbutton

#

but with textbutton easier 💀

shy sail
#

Well you could use UserInputServer when you press left click, but for that you would need a local script and a remote event to fire the server and thats just a headache for something you could do with a button

vast magnet
#

So I should do it with a button, i thought it was pretty easy because I saw it in many clicker games

shy sail
#

Using a button is the easiest way to do it

vast magnet
shy sail
vast magnet