Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My leaderstats script is not working properly?

Asked by 8 years ago
Edited 8 years ago

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

01local DataStore = game:GetService("DataStoreService"):GetDataStore("OnePieceUltimateTreasurePreAlpha")
02 
03game.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)
View all 78 lines...

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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:

1PlayersFolder: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.

Ad

Answer this question