It says line:76 attempt to index local 'PlayersFolder' (a nil value)
and also when the player leaves the folder doesnt delete or go it stays in the server
Additional Info: The stats script is in Workspace and I make the players stats folder go in ServerStorage
01 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "OnePieceUltimateTreasurePreAlpha" ) |
02 |
03 | game.Players.PlayerAdded:connect( function (plr) |
04 | local PlayerStats = Instance.new( "Folder" , game.ServerStorage) |
05 | PlayerStats.Name = plr.Name |
06 | local Level = Instance.new( "IntValue" , PlayerStats) |
07 | Level.Name = "Level" |
08 | Level.Value = 1 |
09 | local LevelEXP = Instance.new( "IntValue" , PlayerStats) |
10 | LevelEXP.Name = "LevelEXP" |
11 | LevelEXP.Value = 0 |
12 | local Melee = Instance.new( "IntValue" , PlayerStats) |
13 | Melee.Name = "Melee" |
14 | Melee.Value = 1 |
15 | local MeleeEXP = Instance.new( "IntValue" , PlayerStats) |
For starters, the reason the player's folder doesn't remove is because you never made it remove when they leave.
You'll need to add:
1 | PlayersFolder:Destroy() |
Right before end when they're leaving.
As for the main issue, no idea, sorry.
EDIT1:
Found out the issue!
Since in studio, it is still there, you need to add a wait() at the beginning of the anon. function, to show that they're not equal in times of running. I don't know any other way to explain it, but add wait() first.