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

This save script still isnt working even after adding everything perfectly?

Asked by 3 years ago
local dataStore = game:GetService("DataStoreService"):GetDataStore("randommeusumtime")

starterRolls = 0


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

    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr

    local points = Instance.new("IntValue")
    points.Name = "Time Spent" 
    points.Value = dataStore:GetAsync(plr.UserId)
    points.Parent = leaderstats
    while true do
        wait(1)
        points.Value = points.Value + 1
    end

end)

game:BindToClose(function(plr)

    dataStore:SetAsync(plr.UserId, plr.leaderstats["Time Spent"].Value)

end)

Save script wont work. Very bogus since 4 others have fixed it, but save scripts hate me.

0
edited my answer. try now. Nozazxe 107 — 3y

1 answer

Log in to vote
0
Answered by
Nozazxe 107
3 years ago
Edited 3 years ago
local ds = game:GetService("DataStoreService")
local ds1 = ds:GetDataStore("randommeusumtime")

starterRolls = 0

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

    local folder = Instance.new("Folder", player)
    folder.Name = "leaderstats"

    local points = Instance.new("IntValue", folder)
    points.Name = "Time Spent"

    points.Value = ds1:GetAsync(player.UserId) or 0
    ds1:SetAsync(player.UserId, points.Value)


end)

game.Players.PlayerRemoving:Connect(function(player)

    local points = player.leaderstats["Time Spent"]

    ds1:SetAsync(player.UserId, points.Value)

end)

game.Players.PlayerAdded:Connect(function(player)
local folder = player:WaitForChild("leaderstats")
local points folder:WaitForChild("Time Spent")
while true do
wait(1)
points.Value = points.Value +1
end
end)

Try this. not sure whats not working.

0
No, this ruined it. Jakob_Cashy 79 — 3y
0
ok try now. Nozazxe 107 — 3y
Ad

Answer this question