hullo, can someone help me this is my script
im dumb and still learning
local players = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local playerDataStore = dataStoreService:GetDataStore("PlayerData")
players.PlayerAdded:Connect(function(player)
local success, data = pcall(function()
return playerDataStore:GetAsync("Player_"..player.UserId)
end)
if success and data then
print(player.Name.." has played before")
game.StarterGui.ScreenGui.Frame.Visible = true
else
print(player.Name.." is new to the game")
game.StarterGui.ScreenGui.Frame2.Visible = true
local success, err = pcall(function()
playerDataStore:SetAsync("Player_"..player.UserId, true)
end)
if not success then
warn("Error saving data for "..player.Name..": "..err)
end
end
end)
i watched a yt tutorial but idk how to use removeasync
,thx
This is easy… other than you have to wait from them to login to remove it.
There are other ways… DataStore Editor, is worth the investment in my opinion.
local dataStoreService = game:GetService("DataStoreService")
local playerDataStore = dataStoreService:GetDataStore("PlayerData")
pcall(function()
playerDataStore:RemoveAsync("Player_"..player.UserId)
end)
If you’re doing your data like that, Id say you’re watching the wrong Video.
Watch This one by MonzterDev
This is significantly better. Id just trash what you got and watch this, I know this might seem overwhelming but if you’re serious about doing things better than you are now you can DM me and I will help you with this.