Hello!
I’m making a login gui, so i nead to DataStore Text, but i don’t know how to save it…
can anyone help?
Thanks!
1 Like
Normal script in ServerScriptService:
local Messages = {" is awesome!", " is cool!", " is epic!"} -- Add as many messages you want right there! Make sure to add a space at the beginning!
local DataStore = game:GetService("DataStoreService"):GetDataStore("Data")
local Players = game:GetService("Players")
local function GetAsync(Player: Player)
pcall(function()
return DataStore:GetAsync(Player.UserId.."-Data") or Player.Name..Messages[math.random(#Messages)]
end)
end
local function SetAsync(Player: Player)
pcall(function()
DataStore:SetAsync(Player.UserId.."-Data", Player.Name..Messages[math.random(#Messages)])
return print("Awesome!")
end
end
Players.PlayerAdded:Connect(function(Player)
Player.PlayerGui.TextGui.TextBox.Text = GetAsync(Player) -- Change TextGui.TextBox.Text to your GUI info stuff.
end)
Players.PlayerRemoving:Connect(function(Player)
SetAsync(Player)
end)
Should work as a base for you to understand this concept!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.