I posted a question earlier about making items appear in the backpack every time a player respawns, and I solved that problem. Now, whenever a player joins, it doesn't give them any gear items until after they respawn. Also, once they level up, it doesn't update their gear, so they are always stuck with the same level gear that they started with. I don't really know how to fix this problem, and need some help!
(This is just a piece of the larger script)
game.Players.PlayerAdded:connect(function(player)
local lev0 = false
local lev1 = false
while true do
local statstore = game:GetService("DataStoreService"):GetDataStore("levels")
key = "user_" .. player.userId
local stats = statstore:GetAsync(key)
if stats >= 0 and lev0 == false then
local flashlight = game.ServerStorage.Flashlight:Clone()
flashlight.Parent = player.Backpack
flashlight.Parent = player.StarterGear
lev0 = true
end
if stats >= 1 and lev1 == false then
local gravcoil = game.ServerStorage.GravityCoil_Level1:Clone()
gravcoil.Parent = player.Backpack
gravcoil.Parent = player.StarterGear
lev1 = true
end

2 comments
First thing would be to add a wait value.
Where?