This is because you are using the PlayerRemoving function, which fires right before/during the time the player is removed from the game. By time you are trying to get the player’s data, it is already gone. This is why people use DataStores (preferably DataStore2), and folders stored in the server to store data as they do not automatically delete upon a player leaving the game.
Are you using .PlayerAdded? Sometimes you will load before the script, and out of good practice you should make a PlayerAdded function, loop through all existing players to fire the PlayerAdded, then hook the PlayerAdded event to the function. Example:
local Players = game:GetService("Players")
local function PlayerAdded(Player)
print("Player has joined!", Player)
end
for _,v in pairs (Players:GetPlayers()) do
PlayerAdded(v)
end
Players.PlayerAdded:Connect(PlayerAdded)
**DB FUNCTION -- REMOVED**
game:GetService("Players").PlayerAdded:Connect(function(p)
**DB FUNCTION -- REMOVED**
if not (Success) then
warn("DATABASE DOWN. PLEASE REPORT TO DATABASE HEAD. [[PINKSARCASM,A_ROXN]]")
elseif Value.Value == nil then
print(p.Name.." does not have a daily.")
game:GetService("ReplicatedStorage").LoaderReplicated.Donate:FireClient(p,"nodaily",0)
else
**DB FUNCTION -- REMOVED**
local data = script.Daily:Clone()
data.Parent = workspace
data.Days = days
data.Next = nextd
data.Void = void
warn(data.Parent)
print("Loaded "..p.Name.."'s data.")
wait(1)
if tonumber(nextd) > os.time() and os.time() > tonumber(void) then
game:GetService("ReplicatedStorage").LoaderReplicated.Donate:FireClient(p,"REDACTED",days)
elseif tonumber(nextd) < os.time() then
print(p.Name.." can not get daily yet.")
elseif tonumber(nextd) > os.time() and os.time() < tonumber(void) then
game:GetService("ReplicatedStorage").LoaderReplicated.Donate:FireClient(p,"REDACTED",days)
end
end
end)
end)
game:GetService("Players").PlayerRemoving:Connect(function(p)
local nextd = game:GetService("Players")[p.Name].Daily.Next.Value
local void = game:GetService("Players")[p.Name].Daily.Void.Value
local days = game:GetService("Players")[p.Name].Daily.Days.Value
**DB FUNCTION -- REMOVED**
**DB FUNCTION -- REMOVED**
if not (Success) then
print(ServerResponse)
else
print("AAAAAAAA")
end
end)
end)```
local Players = game:GetService("Players") --Get Players so we don't keep indexing for it
local ReplicatedStorage = game:GetService("ReplicatedStorage") --Get ReplicatedStorage so we don't keep indexing for it
local LoaderReplicated = ReplicatedStorage:WaitForChild("LoaderReplicated") --Wait for whatever this is
local DonateRemote = LoaderReplicated:WaitForChild("Donate") --Wait for the donate remote
local function PlayerAdded(p) --Function for when player is added
if not (Success) then
warn("DATABASE DOWN. PLEASE REPORT TO DATABASE HEAD. [[PINKSARCASM,A_ROXN]]")
elseif Value.Value == nil then
print(p.Name.." does not have a daily.")
DonateRemote:FireClient(p,"nodaily",0)
else
local data = script.Daily:Clone()
data.Parent = p
data.Days = days
data.Next = nextd
data.Void = void
warn(data, data.Parent)
print("Loaded "..p.Name.."'s data.")
wait(1)
if tonumber(nextd) > os.time() and os.time() > tonumber(void) then
DonateRemote:FireClient(p,"REDACTED",days)
elseif tonumber(nextd) < os.time() then
print(p.Name.." can not get daily yet.")
elseif tonumber(nextd) > os.time() and os.time() < tonumber(void) then
DonateRemote:FireClient(p,"REDACTED",days)
end
end
end
Players.PlayerRemoving:Connect(function(p)
local Daily = p:FindFirstChild("Daily") --Get the daily in the player, won't error if it's not there.
if not Daily then
error("Something has gone wrong, there's no daily in Player.") --Let us know something went wrong.
end
local nextd = Daily.Next.Value
local void = Daily.Void.Value
local days = Daily.Days.Value
if not (Success) then
print(ServerResponse)
else
print("AAAAAAAA")
end
end)
for _,Player in pairs (Players:GetChildren()) do
PlayerAdded(Player) --A player loaded before the code, call the function
end
Players.PlayerAdded:Connect(PlayerAdded) --Connect the script signal to the function we have