|
Players.PlayerAdded:Connect(function(plr)
--Creating Data Table--
PlayersDataTable[plr] = {}
--Loading Data--
local PlayerUserIDkey = plr.UserId
local SavedData = DSS:GetAsync(PlayerUserIDkey)
if SavedData then -- Check If SavedData Is Found
PlayersDataTable[plr] = SavedData
print(plr.Name..' SavedData Was Found')
else -- If SavedData was not Found
PlayersDataTable[plr].Cash = 1000
PlayersDataTable[plr].TimeStamp = os.time()
PlayersDataTable[plr].DevProducts = {}
DSS:SetAsync(PlayerUserIDkey,PlayersDataTable[plr])
print(plr.Name..' SavedData was not Found')
end
PlayersDataTable[plr].Gamepass = {}
for i , v in pairs(GamepassIDs) do
if GPS:PlayerHasPass(plr,v) then
PlayersDataTable[plr].Gamepass = {i = true}
else PlayersDataTable[plr].Gamepass = {i = false}
end
end
PlayersDataTable[plr].Player = plr
DSRE:FireClient(plr,PlayersDataTable[plr])
end)
Gamepass and Player prints >> nil
This is Reality, NOT a Dream. |
|
AjastraJoin Date: 2017-08-01 Post Count: 1461 |
You're loading guest's data. To check if a player is a guest, see if their player.UserId < 1.
Why are you saving player data when they join the game? There is no reason to do this.
Also, you should make sure you manage gamepasses when the player buys them in the server after joining.
"PlayersDataTable[plr].Player = plr"
What is the point of this?
"PlayersDataTable[plr].Gamepass = {i = true}"
You're going to constantly overwrite the Gamepass table.
|
|
|
I'm not loading Guest Data , It's my own data , I am testing in studio
And I am saving data after the Cash is set , no after the player joined
I know how to manage gamepasses , I am passing the Table to the Client
"PlayersDataTable[plr].Player = plr" , I might need to reference the player
This is Reality, NOT a Dream. |
|
AjastraJoin Date: 2017-08-01 Post Count: 1461 |
Well don't deploy the code in prod if this is just a test.
There is no reason to save when the player joins, you should remove the call.
"PlayersDataTable[plr].Player = plr"
This is not necessary because the player is already the key.
|
|
|
nvm , I did something wrong when printing
--Correct--
DSRE.OnClientEvent:Connect(function(Info)
PlayersDataTable[plr].Cash = 1000
end)
print(1,Info.Cash)
--Wrong--
DSRE.OnClientEvent:Connect(function(Info)
PlayersDataTable[plr].Cash = 1000
end)
print(1,Info.[1])
--
Gamepass is a Hashed Table , I used the Name of the gamepass as a Key and set it to True if the player has it , So I am not overwriting anything
This is Reality, NOT a Dream. |
|
AjastraJoin Date: 2017-08-01 Post Count: 1461 |
Yes, you are. You are overwriting the Gamepass key every single time. This will only work for one gamepass.
|
|
|
local GamepassIDs = {MVP = ID , MetTheCreator = ID} -- ID TO AVOID TAGS -__-
for i , v in pairs(GamepassIDs) do
print(i,v)
if GPS:PlayerHasPass(plr,v) then
PlayersDataTable[plr].Gamepass[i] = true
print(PlayersDataTable[plr].Gamepass[i])
else
PlayersDataTable[plr].Gamepass[i]= false
print(PlayersDataTable[plr].Gamepass[i])
end
end
This is Reality, NOT a Dream. |
|
iHydorrJoin Date: 2012-11-29 Post Count: 414 |
You have a "Met the Creator" Gamepass? |
|
|
It' just a name don't mind it ,
I uploaded an Image for a Badge as a Gamepass to test what it looks like
This is Reality, NOT a Dream. |
|