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

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

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.

1 comment

0

edited my answer. try now.

1 answer

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.

2 comments

0

No, this ruined it.

0

ok try now.

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