is there a way to stop the health generation until like a sertain 'lvl' like
if game.Players.LocalPlayer.leaderstats.Level.Value >= 15 then -- health regen + 100 every second end
and if you are like below lvl 15 then you get 0 health per second. is there a way to edit the health script like that ?
if there is allot or something missing just comment and ill edit the question.
When you spawn a script is created in the character called "Health" which is where the players health regeneration is done.
There are multiple ways of doing this but the way I would do this is to delete the Health script when the character spawns.
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(charModel) charModel:WaitForChild('Health'):Destroy() -- deletes the script end) end)
We can then check the players level ect then connect a new function which will be similar to the Heath script.
This is just an example server script
local function healthRegen(incAmount, hum) local deb = false -- we return a new function to be used in our health regenoration return function() -- debounce if deb then return end deb = true -- we pick the lowest value -- hum.Health + (incAmount * wait(1)) we add to the health the inc amount * the time waited hum.Health = math.min(hum.MaxHealth, hum.Health + (incAmount * wait(1)) deb = false end end game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(charModel) charModel:WaitForChild('Health'):Destroy() -- deletes the script local hum = charModel:WaitForChild('Humanoid') if [ check the players level here] then hum.HealthChanged:Connect(healthRegen([some value], hum)) end end) end)
I hope this helps, please comment if you do not understand how / why this script works.
Tell me if this helps at all
local Player = game.Players.LocalPlayer local leaderstats = Player:FindFirstChild("leaderstats") local Level = leaderstats:FindFirstChild("Level") if Level.Value >= 15 then while true do wait(1) --Change this to what you consider a second Player.Humanoid.Health = Player.Humanoid.Health + 100 --Change this to how much they regen end end