#why i get this 64 coins error

1 messages · Page 1 of 1 (latest)

steady pendant
#

i get 64 coins after coins destroy, everything in script is suppose to be fine

steady pendant
#

i tried using debounce it didnt fix

#

so i deleted a part of my script and now its fixed

#

but its strange because i had to delete stats saving scripts

#

now im struggliing making the script again i have errors

shell mortar
#

What's the script?

steady pendant
#

gimme few min imma write it again and send

#

if u can help me

shell mortar
#

I can try

steady pendant
#
local dataStore = game:GetService("DataStoreService")
local data = dataStore:GetDataStore("Stats")

game.Players.PlayerAdded:Connect(function(plr)

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr
    
    local jumpPower = Instance.new("NumberValue")
    jumpPower.Name = "Jump Power"
    jumpPower.Value = 15
    jumpPower.Parent = leaderstats
    
    local wins = Instance.new("NumberValue")
    wins.Name = "Wins"
    wins.Value = 0
    wins.Parent = leaderstats

    local coins = Instance.new("NumberValue")
    coins.Name = "Coins"
    coins.Value = 0
    coins.Parent = leaderstats
    
    local jumpPower
    local wins
    local coins
    
    jumpPower = data:GetAsync(plr.UserId.."-Jump Power")
    wins = data:GetAsync(plr.UserId.."-Wins")
    coins = data:GetAsync(plr.UserId.."-Coins")
    
    if jumpPower ~= nil then 
        
        plr.leaderstats.jumpPower.Value = jumpPower
    end
    
    if wins ~= nil then 

        plr.leaderstats.wins.Value = wins
    end
    
    if coins ~= nil then 

        plr.leaderstats.coins.Value = coins
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    
    local sucess, errormsg = pcall(function()
        
        data:SetAsync(plr.UserId.."-Jump Power", plr.leaderstats.jumpPower.Value)
        data:SetAsync(plr.UserId.."-Wins", plr.leaderstats.wins.Value)
        data:SetAsync(plr.UserId.."-Coins", plr.leaderstats.Coins.Value)
        
    end)
    
end)
steady pendant
#

im a beginner so my script may be wrong

#

but all is supposed to work i dont get it

shell mortar
#

Like the second time

steady pendant
#

Bew

#

Bdw

#

I changed all code

#

Now it works

shell mortar
#

So then ur all good?

steady pendant
#

I have to admit i got bored and use chatgpt

steady pendant
shell mortar
#

Like if it can fix something by all means go ahead

steady pendant
shell mortar
#

Ask it to explain it to you

steady pendant
steady pendant
shell mortar
steady pendant
#

Thanks