#When i edit currency on panel its saving but when i increase it with button it doesnt save

13 messages · Page 1 of 1 (latest)

tired trench
#
local DSS = game:GetService('DataStoreService')
local mainDS = DSS:GetDataStore('CoinsData')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Events = ReplicatedStorage:FindFirstChild('Events')


game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new('Folder', player)
    leaderstats.Name = "leaderstats"

    local coins = Instance.new("IntValue", leaderstats)
    coins.Name = "Coins"


    local data = mainDS:GetAsync(player.UserId)

    if data then
        if data[1] then
            coins.Value = data[1]
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local leaderstats = player:WaitForChild("leaderstats")
    local coins = leaderstats:WaitForChild("Coins")

    mainDS:SetAsync(player.UserId, {coins.Value})
end)
Button = script.Parent
player = game.Players.LocalPlayer

Button.MouseButton1Click:Connect(function()
    local leaderstats = player:WaitForChild("leaderstats")
    local coins = leaderstats:WaitForChild("Coins")
    coins.Value += 1
    
end)

#

first one is normal second one is local script

full stoneBOT
#

studio** You are now Level 1! **studio

heavy mulch
#

It must be done on server scripts

tired trench
#

but

#

i cant use button from normal scripts

violet olive
heavy mulch
#

It will teach you what you need to know

tired trench
#

thanks guys

#

ur like a hero

violet olive