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

Data store questions?

I am making a test datastore but I have some issues, I am not sure how to fix em, nor what to stick in their place.

game.Players.PlayerAdded:connect(function(player)
local PDataStore = game:GetService("DataStoreService"):GetDataStore(player.UserID)
PDataStore:SetAsync("Money", 50)

player.PlayerGui.ScreenGui.TextBox.Text = Variant  GlobalDataStore:GetAsync(
   string "Money"
)
end)

What do I add to the Variant? I don't know what to define it with, Also, my datastore isn't global, its one datastore per person, I also got a blue line uder string "Money"

1 answer

✓ Accepted answer

:GetAsync() is a method, which you use on the DataStore that you got on line 2. 'Variant' and 'string' are data types, which you don't include in the actual script. I recommend reading the wiki for more examples, you can find the page here.

game.Players.PlayerAdded:connect(function(player)
	local PDataStore = game:GetService("DataStoreService"):GetDataStore(player.UserID)
	PDataStore:SetAsync("Money", 50)

	local money = PDataStore:GetAsync("Money")
	player.PlayerGui.ScreenGui.TextBox.Text = money --// I'd recommend doing GUI stuff client side, but it's up to you.
end)

Hope this helped.

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