I have an IntValue inside of the player which is added through a script in ServerScriptService, it works, but whenever the player dies the IntValue goes back to 0, anyone know a fix?
Script in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
local PlayerStats = Instance.new("Folder", player)
PlayerStats.Name = "PlayerStats"
local Candy = Instance.new("IntValue", PlayerStats)
Candy.Value = 250
Candy.Name = "Candy"
local QuestInfo = Instance.new("Folder", player)
QuestInfo.Name = "QuestInfo"
local BrainHunt = Instance.new("Folder", QuestInfo)
BrainHunt.Name = "BrainHunt"
local InProgress = Instance.new("BoolValue", BrainHunt)
InProgress.Name = "InProgress"
InProgress.Value = false
local NumberOfBrains = Instance.new("IntValue", BrainHunt)
NumberOfBrains.Name = "NumberOfBrains"
NumberOfBrains.Value = 0
local Completed = Instance.new("BoolValue", BrainHunt)
Completed.Name = "Completed"
Completed.Value = false
end)```
There’s nothing visibly wrong with this code, have you checked to see if you have anything running when the character dies or anything else resetting the values?