local button = script.Parent
local player = game.Players.LocalPlayer
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.ClickEvent:FireServer()
end)local event = game.ReplicatedStorage.ClickEvent
event.OnServerEvent:Connect(function(player)
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
leaderstats.Coins.Value += 1
end
end)game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = stats
end)local price = 10
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local coins = player.leaderstats.Coins
if coins.Value >= price then
coins.Value -= price
game.ReplicatedStorage.UpgradeEvent:FireServer()
end
end)game.ReplicatedStorage.UpgradeEvent.OnServerEvent:Connect(function(player)
player:SetAttribute("Multiplier", (player:GetAttribute("Multiplier") or 1) + 1)
end)local multiplier = player:GetAttribute("Multiplier") or 1
leaderstats.Coins.Value += 1 * multiplierlocal DataStoreService = game:GetService("DataStoreService")
local store = DataStoreService:GetDataStore("PlayerData")
game.Players.PlayerAdded:Connect(function(player)
local data = store:GetAsync(player.UserId)
if data then
player.leaderstats.Coins.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(player)
store:SetAsync(player.UserId, player.leaderstats.Coins.Value)
end)