Click for coins tutorial

How to make a 'Click For Coins' gui in Roblox (Maybe Outdated)

by kvxyIie

Author Avatar

First, add a screen gui into 'StarterGui' and then in that add a text button.

You can call the button whatever you want, but something relevent.

For the actual text the button will display, change that to 'Click For Coins!' In the text button, add a LocalScript

Variables!

local Player = game.Players.LocalPlayer
 -- Creates a 'Player' variable
local Coins = Player.leaderstats:WaitForChild("Coins")
 -- Creates a 'Coins' variable
local Button = script.Parent
 -- Creates a 'Button' variable

'Click For Coins' script!

Button.MouseButton1Click:Connect(function()

    Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + 1

wait(.05)

end)

Overall, it should look like this:


-- Variables
local Player = game.Players.LocalPlayer
local Coins = Player.leaderstats:WaitForChild("Coins")
local Button = script.Parent


-- Click for coins script
Button.MouseButton1Click:Connect(function()
    Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + 1
wait(.05)

end)

In the ScreenGui, add in a text label, name it CoinsDisplay Inside of it, add in a local script

Coins Display gui!

Variables!

local Player = game.Players.LocalPlayer
 -- Creates a 'Player' variable
local Coins = Player.leaderstats:WaitForChild("Coins") -- Creates a 'Coins' variable

Coins display

script.Parent.Text = "Coins: " .. Coins.Value

Coins:GetPropertyChangedSignal("Value"):Connect(function()
    script.Parent.Text = "Coins: " .. Coins.Value
end)

Overall, it should look like this:


--Variables
local Player = game.Players.LocalPlayer
local Coins = Player.leaderstats:WaitForChild("Coins")

 --Display

script.Parent.Text = "Coins: " .. Coins.Value

Coins:GetPropertyChangedSignal("Value"):Connect(function()
    script.Parent.Text = "Coins: " .. Coins.Value
end)