How to make a Clicker Game on Roblox || Part 1
________________________________________________________________
–leaderboard script:
local datastore = game:GetService(“DataStoreService”):GetDataStore(“DataStore”)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Parent = player
leaderstats.Name = “leaderstats”
local Clicks = Instance.new(“NumberValue”)
Clicks.Parent = leaderstats
Clicks.Name = “Clicks”
local Rebirths = Instance.new(“NumberValue”)
Rebirths.Parent = leaderstats
Rebirths.Name = “Rebirths”
local key = “user-” .. player.userId
local storeditems = datastore:GetAsync(key)
if storeditems then
Clicks.Value = storeditems[1]
Rebirths.Value = storeditems[2]
else
local items = {Clicks.Value, Rebirths.Value}
datastore:SetAsync(key, items)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local items = {player.leaderstats.Clicks.Value, player.leaderstats.Rebirths.Value}
local key = “user-” .. player.userId
datastore:SetAsync(key, items)
end)
___________________________________________________________________________
–Local Script for clicker button
script.Parent.MouseButton1Click:Connect(function()
game.Workspace.AddClicks.AddClicks:FireServer()
end)
__________________________________________________
–Script in workspace that gives u clicks:
script.AddClicks.OnServerEvent:Connect(function(player)
player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value +1 — how much u get when u click
end)
__________________________________________________
–text label that shows how much clicks u have
while wait()do
local player = game.Players.LocalPlayer
script.Parent.Text = ” “..player:WaitForChild(“leaderstats”):FindFirstChild(“Clicks”).Value
end
___________________________________________________________________________
anyway guys hope the scripts work for u and make sure to sub and like!
___________________________________________________________________________
—