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
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
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
local Player = game.Players.LocalPlayer
-- Creates a 'Player' variable
local Coins = Player.leaderstats:WaitForChild("Coins") -- Creates a 'Coins' variable
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)