I Basically Want To Know How To Combine Stats Into One. Here's My Current Code
game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder", plr) leaderstats.Name = "leaderstats" local Strength = Instance.new("IntValue", leaderstats) Strength.Name = "Strength" local Endurance = Instance.new("IntValue", leaderstats) Endurance.Name = "Endurance" local Psychic = Instance.new("IntValue", leaderstats) Psychic.Name = "Psychic" local TotalPower = Instance.new("IntValue", leaderstats) TotalPower.Name = "Total Power" TotalPower.Value = Strength.Value + Endurance.Value + Psychic.Value
This code looks fine however, you need to refresh the "Total Power" Value each time one of the other stats increase. For example
game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder", plr) leaderstats.Name = "leaderstats" local Strength = Instance.new("IntValue", leaderstats) Strength.Name = "Strength" local Endurance = Instance.new("IntValue", leaderstats) Endurance.Name = "Endurance" local Psychic = Instance.new("IntValue", leaderstats) Psychic.Name = "Psychic" local TotalPower = Instance.new("IntValue", leaderstats) TotalPower.Name = "Total Power" TotalPower.Value = Strength.Value + Endurance.Value + Psychic.Value function refresh() --we make a new function so it's easier to refresh later TotalPower.Value = Strength.Value + Endurance.Value + Psychic.Value end for index,value in ipairs(leaderstats:GetChildren()) do --for every stat do value.Changed:Connect(function() --whenever the stat changes we want to refresh the total power value refresh() end) end end)
(This code may not work, I haven't tested it.)