Backstory
So I made a simulator, tested everything in studio and it was working fine. I release it, and the clicking part broke. I am pretty sure it has to do with the data store. I know this because the data store was saving the level value as 0 when it should be 1. This causes the clicking to do nothing because it multiplies 10 by the level.
How I tried to solve it.
At first I changed the data store key. It didn’t do anything except make it worse. Every time I clicked it gave me an insane amount. But for others they couldn’t click at all. So I don’t know if I am doing the data store wrong or if it is something else.
Data Store Script
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("dsaferw")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Claps = Instance.new("IntValue")
Claps.Name = "Claps"
Claps.Parent = leaderstats
local totalClaps = Instance.new("IntValue")
totalClaps.Name = "totalClaps"
totalClaps.Parent = player
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = leaderstats
local Plus = Instance.new("NumberValue")
Plus.Name = "Plus"
Plus.Parent = player
Plus.Value = 1
local Money = Instance.new("IntValue")
Money.Name = "Money"
Money.Parent = leaderstats
local KeyLevel = Instance.new("IntValue")
KeyLevel.Name = "KeyLevel"
KeyLevel.Parent = player
local playerUserId = "Player_"..player.UserId
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(playerUserId)
end)
if success and data then
Claps.Value = data[1]
Level.Value = data[2]
Plus.Value = data[3]
Money.Value = data[4]
totalClaps.Value = data[5]
KeyLevel.Value = data[7]
else
print("Data not found")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player_"..player.UserId
local data = {
player.leaderstats.Claps.Value;
player.leaderstats.Level.Value;
player.leaderstats.Money.Value;
player.Plus.Value;
player.totalClaps.Value;
player.KeyLevel.Value
}
local success, errormessage = pcall(function()
myDataStore:SetAsync(playerUserId, data)
end)
if success then
print("Data saved")
else
print("Error in saving data")
warn(errormessage)
end
end)
Clicking Scripts
local player = game.Players.LocalPlayer
local animation = script.Animation
local char = workspace:FindFirstChild(player.Name)
local humanoid = char:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(animation)
local debounce = false
local function clap()
animationTrack:Play()
script.Clap:Play()
wait(1.16)
game:GetService("ReplicatedStorage").GiveCoins:FireServer(player)
animationTrack:Stop()
script.Clap:Stop()
end
script.Parent.MouseButton1Click:Connect(function()
if not debounce then
debounce = true
clap()
wait()
debounce = false
end
end)
script.Parent.MouseEnter:Connect(function()
script.Parent.TextButton_Roundify_2px.ImageColor3 = Color3.fromRGB(0, 95, 143)
end)
script.Parent.MouseLeave:Connect(function()
script.Parent.TextButton_Roundify_2px.ImageColor3 = Color3.fromRGB(00, 170, 255)
end)
script.Parent.TouchTap:Connect(function()
if not debounce then
debounce = true
clap()
wait()
debounce = false
end
end)
game:GetService("ReplicatedStorage").GiveCoins.OnServerEvent:Connect(function(player)
player.leaderstats.Claps.Value = player.Plus.Value * 10 + player.leaderstats.Claps.Value
player.totalClaps.Value = player.Plus.Value * 10 + player.totalClaps.Value
end)
Level Up Scripts
local levelUp = game:GetService("ReplicatedStorage").LevelUp
local buyKey = game:GetService("ReplicatedStorage").BuyKey
levelUp.OnServerEvent:Connect(function(player)
player.leaderstats.Level.Value = player.leaderstats.Level.Value + 1
player.Plus.Value = player.Plus.Value + 1
end)
buyKey.OnServerEvent:Connect(function(player, value)
wait(2)
player.KeyLevel.Value = player.KeyLevel.Value + 1
player.leaderstats.Money.Value = player.leaderstats.Money.Value - value
end)
local levelUp = game:GetService("ReplicatedStorage").LevelUp
local player = game.Players.LocalPlayer
player.leaderstats.Claps:GetPropertyChangedSignal("Value"):Connect(function()
if player.totalClaps.Value >= player.Plus.Value * player.Plus.Value * 1000 then
local object = script.Parent.Frame
levelUp:FireServer(player)
object.Visible = true
wait(2)
object.Visible = false
end
end)