Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I need help with Data Storing, I Want To Save everyone's Wins,?

So everytime Someone wins, Them Get a point, But i want their point to save, Everytime they join/leave server, Please Help!

local Debounce = tick() -- Assign tick() to the variable

game.Players.PlayerAdded:Connect(function(plr)
    local stats = Instance.new("BoolValue", plr)
    stats.Name = "leaderstats"

    local wins = Instance.new("IntValue", stats)
    wins.Name = "Wins"
    wins.Value = 0

workspace.Lobby.Winner.Touched:Connect(function()
    if (tick() - Debounce) >= 5 then -- Make sure 5 seconds have elapsed since last debounce
        Debounce = tick()

            wins.Value = wins.Value + 1
    end
end)

end)

1 comment

0

First of all, please check your grammar before posting as it can be very confusing to read someone's posts if it isn't written correctly. Secondly, I think you are trying to find what is called a "DataStore", here is a link to a wiki article about saving player data and most likely will help with what you are trying to accomplish. https://developer.roblox.com/articles/Saving-Player-Data

1 answer

✓ Accepted answer

Your question was kind of hard to read, but I think I kinda understood what you want. This script would save everyone's wins.

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("winsSaveSystem")--change all "wins" to what value you want and keep doing it 
local Debounce = tick() -- Assign tick() to the variable

game.Players.PlayerAdded:connect(function(plr)
 local folder = Instance.new("Folder", plr)
 folder.Name = "leaderstats"
 local wins = Instance.new("IntValue", folder)
 wins.Name = "Wins"

workspace.Lobby.Winner.Touched:Connect(function()
    if (tick() - Debounce) >= 5 then -- Make sure 5 seconds have elapsed since last debounce
        Debounce = tick()

            wins.Value = wins.Value + 1
    end
end)
 wins.Value = ds1:GetAsync(plr.UserId) or 0
 ds1:SetAsync(plr.UserId, wins.Value)
 

 wins.Changed:connect(function()
  ds1:SetAsync(plr.UserId, wins.Value)
 end)
 
 

end)

Accept this answer if it helped you.

2 comments

0

Thank You Sir!

0

Np

This discussion is preserved as it was. New answers, comments, and votes are closed.