So, I've made the DataStore, and it's working fine. When I wanted it to print "Working" in the Output, it works, which means I've done the DataStore correctly. How would I display it inside a TextLabel? In this case, I got it so you have to touch a part, which is the parent of the script, for it to show the DataStore value. But, the textlabel doesn't do as told.
local datastore = game:GetService("DataStoreService"):GetDataStore("currency")
game.Players.PlayerAdded:connect(function(player)
local key = "user_"..player.userId
datastore:UpdateAsync(key, function(oldcurrency)
local newcurrency = oldcurrency or 0
return newcurrency
end)
end)
game.Players.PlayerAdded:connect(function(player)
script.Parent.Touched:connect(function()
local key = "user_"..player.userId
local coin = datastore:GetAsync(key)
game.StarterGui.ScreenGui.Frame.TextLabel.Text = coin
end)
end)

1 comment
Many thanks!