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)
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.