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

How To Combine Strength, Endurance, Psychic Leader Stats Into One Leader Stat "Total Power"?

Asked by 4 years ago

I Basically Want To Know How To Combine Stats Into One. Here's My Current Code

01game.Players.PlayerAdded:Connect(function(plr)
02    local leaderstats = Instance.new("Folder", plr)
03    leaderstats.Name = "leaderstats"
04 
05    local Strength = Instance.new("IntValue", leaderstats)
06    Strength.Name = "Strength"
07 
08    local Endurance = Instance.new("IntValue", leaderstats)
09    Endurance.Name = "Endurance"
10 
11    local Psychic = Instance.new("IntValue", leaderstats)
12    Psychic.Name = "Psychic"
13 
14    local TotalPower = Instance.new("IntValue", leaderstats)
15    TotalPower.Name = "Total Power"
16    TotalPower.Value = Strength.Value + Endurance.Value + Psychic.Value
0
In the part of the script you are showing, you're adding them together in totalpower to combine them. I assume that would work, so what's the issue? Befogs 113 — 4y
0
when i launch the game, it doesnt seem to show my total power but instead say zero Proskillez342 9 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

This code looks fine however, you need to refresh the "Total Power" Value each time one of the other stats increase. For example

01game.Players.PlayerAdded:Connect(function(plr)
02    local leaderstats = Instance.new("Folder", plr)
03    leaderstats.Name = "leaderstats"
04 
05    local Strength = Instance.new("IntValue", leaderstats)
06    Strength.Name = "Strength"
07 
08    local Endurance = Instance.new("IntValue", leaderstats)
09    Endurance.Name = "Endurance"
10 
11    local Psychic = Instance.new("IntValue", leaderstats)
12    Psychic.Name = "Psychic"
13 
14    local TotalPower = Instance.new("IntValue", leaderstats)
15    TotalPower.Name = "Total Power"
View all 27 lines...

(This code may not work, I haven't tested it.)

Ad

Answer this question