0% found this document useful (0 votes)
22 views2 pages

Player Data Management Script

The script manages player data using Roblox's DataStoreService, checking if a player has joined before and loading their data accordingly. When a player joins, it attempts to retrieve their data and prints messages based on whether they are a returning player or a first-time joiner. Upon player removal, it saves their data and handles any errors that may occur during the process.

Uploaded by

bartekwasiel921
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Player Data Management Script

The script manages player data using Roblox's DataStoreService, checking if a player has joined before and loading their data accordingly. When a player joins, it attempts to retrieve their data and prints messages based on whether they are a returning player or a first-time joiner. Upon player removal, it saves their data and handles any errors that may occur during the process.

Uploaded by

bartekwasiel921
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local DataStoreService = game:GetService("DataStoreService")

local PlayerData = DataStoreService:GetDataStore("PlayerData")

[Link]:Connect(function(player)
if PlayerData:GetAsync([Link].."-HasSeen") then
wait()
else
print("You have Not Joined Before")
end
end)

[Link]:Connect(function(player)

local data

local success, err = pcall(function()


data = PlayerData:GetAsync("playerdata"..[Link])
end)
if data and success then
print("You Have Joined Before")
else
print("First Time Joining")
end

if success then
print("success")
if data then
print("data Collected")
-- data is a table

else

end
else
warn(err)
end

end)
-------------------------------------------------------------

[Link]:Connect(function(player)

local data = {}

local success, err = pcall(function()


PlayerData:SetAsync("playerdata"..[Link], data)
end)

if success then
print("data saved")
else
player:Kick("Error While Loading Your Data")
warn(err)
end
end)

You might also like