Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
GentiRob -81
5 years ago

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)

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 Stephenthefox 94 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

0
Thank You Sir! GentiRob -81 — 5y
0
Np CaptainD_veloper 290 — 5y
Ad

Answer this question