local DataStore = game:GetService("DataStoreService"):GetDataStore("isaplr") --gets simple stored data about player being on server before or not... game.Players.PlayerAdded:connect(function(plr) local key = "user_" .. plr.userId --unique user ID (duh) local char = plr.Character local isaplayr = DataStore:GetAsync(key) --gets data for KEY, which is listed as a local term above for the specific user. if isaplayr.Value == nil then --if the stored value is non-existent (aka never played before) ... DataStore:SetAsync(key,true) --hooray they played! sorta. print("new player yey") elseif isaplayr.Value == true then -- they've already played lol, but for debugging purposes... print("well I guess you aren't special") end end) --sidenote: w0w first script in like a year lmao --another note: pls be sure to save these values in player.. not sure if updating value saves automatically?? /confused
Line 9 is the issue. the local variable "isaplayr" is nil, which is where the script errors, even though I set the function up to detect if its nil and execute the script afterward.
Here is a full bug report from the F9 menu.
Oh and, the purpose of this script is to figure out if the player has joined before. If they've already joined it would be set to true and the script would do nothing. (this is for a GUI meant to only show for new players.)
Figured it out!
local DataStore = game:GetService("DataStoreService"):GetDataStore("isaplr") --gets simple stored data about player being on server before or not... game.Players.PlayerAdded:connect(function(plr) local key = "user_" .. plr.userId --unique user ID (duh) local char = plr.Character local isaplayr = DataStore:GetAsync(key) --gets data for KEY, which is listed as a local term above for the specific user. if isaplayr == nil then --if the stored value is non-existent (aka never played before) ... DataStore:SetAsync(key,true) --hooray they played! sorta. print("new player yey") elseif isaplayr == true then -- they've already played lol, but for debugging purposes... print("well I guess you aren't special") end end)
The issue was that isaplayr has no .Value property, since it was considered NIL (I never played the server before). Even if it wasn't nil, it would've errored because there's no Value property.