#Need Help making a small stats system:

42 messages · Page 1 of 1 (latest)

sturdy hornet
#

I've been working on a stats system in Roblox Studio for the past 3 days. I have a + button that should increase the player's max health. However, I'm facing an issue: after adding stats, the health regeneration stops at 100 instead of the upgraded max health. I even used a 'while true do' loop to print the current health, but it still shows 100 even after upgrading the health. I need help to ensure the health regenerates until it reaches the new max health value.

Here is the health + script:
local player = game.Players.LocalPlayer

local button = script.Parent
local powerLabel = script.Parent.Parent

local powerLevel = 0

local datastore = game:GetService("DataStoreService")
local dataStoreName = "PowerLevelDataStore"

button.MouseButton1Click:Connect(function()
if powerLevel < 1000 then
local leaderstats = player:FindFirstChild("leaderstats")

    if leaderstats then
        local gpValue = leaderstats:FindFirstChild("GP")

        if gpValue and gpValue.Value >= 1 then
            gpValue.Value = gpValue.Value - 1
            powerLevel = powerLevel + 1
            powerLabel.Text = "POWER LVL: " .. tostring(powerLevel)

            local humanoid = player.Character:FindFirstChild("Humanoid")
            if humanoid then
                local currentMaxHealth = humanoid.MaxHealth
                humanoid.MaxHealth = currentMaxHealth + 10
                humanoid.Health = humanoid.MaxHealth  
            end

            -- Save the power level to the data store
            datastore:SetAsync(player.UserId, { powerLevel = powerLevel })
        end
    end
end

end)

-- Load the power level from the data store
local success, data = pcall(function()
return datastore:GetAsync(player.UserId)
end)

if success and data and data.powerLevel then
powerLevel = data.powerLevel
powerLabel.Text = "POWER LVL: " .. tostring(powerLevel)
end

unborn meteor
sturdy hornet
#

nope

#

didnot work either

jolly mortar
#

dude

#

do you not know what += does?

#

humanoid.MaxHealth += 10

#

instead of that

#

@sturdy hornet

#

ma boi

#
-- put your code like this dawg :,(
jolly mortar
#

the thing

#

in workspace

#

like

#

actual humanoid maxhealth

#

see if it changed

unborn meteor
sturdy hornet
#

Yeah it changes the maxHealth tho the health regen stops at 100 @jolly mortar @unborn meteor

#

the same for the blade stats, it should add more on the number value wich is 20 [20 is the normal blade damage] it adds on the blade damage tho it also doesnot deal anymore damage more than 20.

#

i tried printing the current value of the script tho it did this:

#

test

--test
unborn meteor
jolly mortar
#

are you using a local script?

#

theres server and local

#

local is your pc

#

server is EVERYONE

#

if you change something locally, well, its only for your pc

#

so you have to change it for everyone

sturdy hornet
#

i want to change it to the local player.

sturdy hornet
#

@jolly mortar @unborn meteor The health regen stops at 100 and doesnot go beyond, Am i supposed to meake it a server script, tho that will change it to everyone.

silk muskBOT
#

studio** You are now Level 2! **studio

unborn meteor
#

It's probably because it's a localscript?