Why won't my backpack script update the players gear after they level up?
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)
01 | game.Players.PlayerAdded:connect( function (player) |
07 | local statstore = game:GetService( "DataStoreService" ):GetDataStore( "levels" ) |
08 | key = "user_" .. player.userId |
09 | local stats = statstore:GetAsync(key) |
11 | if stats > = 0 and lev 0 = = false then |
12 | local flashlight = game.ServerStorage.Flashlight:Clone() |
13 | flashlight.Parent = player.Backpack |
14 | flashlight.Parent = player.StarterGear |
17 | if stats > = 1 and lev 1 = = false then |
18 | local gravcoil = game.ServerStorage.GravityCoil_Level 1 :Clone() |
19 | gravcoil.Parent = player.Backpack |
20 | gravcoil.Parent = player.StarterGear |