ActionReciever(Script)
local debounce = false
game.ReplicatedStorage.Action.OnServerEvent:Connect(function(player,action)
if action == "Click" then
if debounce == true then
else
debounce = true
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1*(player.leaderstats.Rebirths.Value + 1)
wait(0.2)
debounce = false
end
end
end)
leaderstats & Data Saving(Script)
local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetDataStore("Points")
local rebirthsStore = DataStoreService:GetDataStore("Rebirths")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local points = Instance.new("IntValue",leaderstats)
points.Name = "Points"
points.Value = pointsStore:GetAsync(player.UserId) or 0
local rebirths = Instance.new("IntValue",leaderstats)
rebirths.Name = "Rebirths"
rebirths.Value = rebirthsStore:GetAsync(player.UserId) or 0
end)
game.Players.PlayerRemoving:Connect(function(player)
pointsStore:SetAsync(player.UserId,player.leaderstats.Points.Value)
rebirthsStore:SetAsync(player.UserId,player.leaderstats.Rebirths.Value)
end)
ClickSender(Local Script)
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function(player)
game.ReplicatedStorage.Action:FireServer("Click")
end)
LocalScript(Local Script)
local player = game.Players.LocalPlayer
player.PlayerGui.Stats.Points.TextLabel.Text = player.leaderstats:WaitForChild("Points").Value
player.PlayerGui.Stats.Rebirths.TextLabel.Text = player.leaderstats:WaitForChild("Rebirths").Value
player.leaderstats.Points:GetPropertyChangedSignal("Value"):Connect(function()
player.PlayerGui.Stats.Points.TextLabel.Text = player.leaderstats:WaitForChild("Points").Value
end)
player.leaderstats.Rebirths:GetPropertyChangedSignal("Value"):Connect(function()
player.PlayerGui.Stats.Rebirths.TextLabel.Text = player.leaderstats:WaitForChild("Rebirths").Value
end)
Rebirth(LocalScript)
local player = game.Players.LocalPlayer
script.Parent.Frame1.TextButton.Activated:Connect(function()
if script.Parent.Frame.Visible == true then
script.Parent.Frame.Visible = false
else
script.Parent.Frame.Visible = true
end
end)
script.Parent.Frame.ExitButton.Activated:Connect(function()
script.Parent.Frame.Visible = false
end)
script.Parent.Frame.RebirthButton.Activated:Connect(function()
if player.leaderstats.Points.Value < (player.leaderstats.Rebirths.Value + 1) * 2500 then
else
player.leaderstats.Points.Value = 0
player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + 1
end
end)
player.PlayerGui.Rebirths.Frame.RebirthButton.Text = "Rebirth for "..(player.leaderstats.Rebirths.Value + 1) * 2500 .." Coins"
player.leaderstats.Rebirths:GetPropertyChangedSignal("Value"):Connect(function()
player.PlayerGui.Rebirths.Frame.RebirthButton.Text = "Rebirth for "..(player.leaderstats.Rebirths.Value + 1) * 2500 .." Coins"
end)
When the player rebirths, the points are reset to 0, but once the player clicks again, their Points go to 2501 instead of 1