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

Data store questions?

Asked by 8 years ago

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

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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

Ad

Answer this question