Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to increase maxhealth?

ok so im trying to make it so the higher your defense stat the more health you have, the part im stuck on is the server script. I have no idea on what to put here so any tips and advice would be great.

local event = game.ReplicatedStorage:WaitForChild("Def")


event.OnServerEvent:Connect(function(player)
    --change INT VALUE here
end)

This is where my Defense stat is stored if that helps

local Stats = player:WaitForChild("Stats")
local Strength = Stats:FindFirstChild("Defense")

2 answers



local event = game.ReplicatedStorage:WaitForChild("Def")


event.OnServerEvent:Connect(function(player)
	local Stats = player:WaitForChild("Stats")
	local Strength = Stats:FindFirstChild("Defense")
	local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
	humanoid.MaxHealth = Strength*ratioofstrengthtomaxhealth
end)

4 comments

0

codeblocks please

0

yeah kinda new to this, edited

0

Sorry if my explanation was worded incorrectly but i need to know what to put in the server-side script so that the remote even activates and changes the max health based on the amount of defense i have

0

yeah was that not it? thats server side

local event = game.ReplicatedStorage:WaitForChild("Def")
local DefaultHealth = 10

event.OnServerEvent:Connect(function(player)
local Stats = player:WaitForChild("Stats")
local Strength = Stats:FindFirstChild("Defense")
local char = plr.Character or plr.CharacterAdded:wait()
if char then
local hum = char:FindFirstChild("Humanoid")
if hum then
hum.MaxHealth = DefaultHealth * Strength.Value
end
end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.