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

What's wrong with this DataStore script?

local ds = game:GetService("DataStoreService"):GetGlobalDataStore("Valor")

game.Players.PlayerAdded:connect(function(player)
	
	local stats = Instance.new("IntValue", player)
	stats.Name = "leaderstats"
	
	local valor = Instance.new("IntValue", stats)
	valor.Name = "Valor"
	
	if ds:GetAsync(player.userId) ~= nil then
		valor.Value = ds:GetAsync(player.userId)
	end
	while true do
		ds:SetAsync(player.userId,valor.Value)
	end
end)

Lookie here,

I've been reviewing the wiki, watching YouTube videos, and checking out other developers' uncopylocked games for hours now.

So help would be GREATLY appreciated.

So the purpose of this script is to save the IntValue "Valor", which it does. However, the catch is I am trying to save it across several games.

What I'm looking for here is an explanation as of to how the entire universe thing works, and as of to how to make this work across several games.

1 comment

0

Tip: Make it while wait() do. If it doesn't wait, it'll crash your game.

1 answer

✓ Accepted answer

Fix: That while loop isn't very good, it'll just lag the player. Instead, make it a .Changed event:

valor.Changed:connect(function()
	ds:SetAsync(player.UserId,valor.Value)
end)

To answer your question:

Wiki article: http://wiki.roblox.com/index.php?title=Game

You shouldn't need to do anything special, DataStores carry across universes. Just make sure to put that script into every place in the universe.

Hopefully this helped, if you need anything, tell me in the comments!

~TDP

2 comments

0

Is it possible to do it without a universe? The games I want to connect it across are several games and it'd be a pain I really don't want people to have go to the universe just for points to save.

0

Yes, it only works on the universe. You could try using something like trello, but I wouldn't recommend it since you're making files for each player.

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