Hello, I’m not sure why this is happening but I have a Stats folder inside each player, along with a default one inside of ServerStorage.
When I run the code to reset all the values of these, it only prints “Loadr” and it’s supposed to print every value. (It also doesn’t reset the values)
Code:
local function Reset(player, stats)
for _, stat in pairs(stats:GetChildren()) do
print(stat.Name)
if stat:IsA("ModuleScript") then
return
end
--===
if Assets.Players.Stats:FindFirstChild(stat.Name) then
stat.Value = Assets.Players.Stat:FindFirstChild(stat.Name).Value
print("Reset "..stat.Name)
end
end
end
-- events --
PlayerManager.JoinListener(function (player: Player)
print("Player joined, loading data. ("..player.Name..")")
--===
local Stats = Assets.Players.Stats:Clone()
local stats = Stats
stats.Parent = player
--===
player.CharacterAdded:Connect(function (Character)
player.CharacterAppearanceLoaded:Wait()
--===
Reset(player, player.Stats)
--===
local PlayerData = PlayerManager[player.Name]
--===
local Weapon = player.Stats.Weapon
if Weapon.Value then
Weapon.Value:Destroy()
Weapon.Value = nil
end
--===
local hold = Instance.new("Attachment")
hold.CFrame = workspace.Anim.Torso.Hold.CFrame
hold.Axis = Vector3.new(1, -0, 0)
hold.SecondaryAxis = Vector3.new(0, 1, 0)
hold.Name = "Hold"
hold.Parent = Character.Torso
--===
PlayerData:GiveWeapon()
--===
if Character:FindFirstChild("Animator") then
Character:FindFirstChild("Animator"):Destroy()
end
--if Character:FindFirstChild("Health") then
-- Character:FindFirstChild("Health"):Destroy()
--end
--===
Character.Humanoid.WalkSpeed = player.Stats.Walkspeed.Value
end)
end)
I already tried to go through the default one and look for it in the player version but it had the same result. Any idea why this is happening?