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

How to increase maxhealth?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago


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)
0
codeblocks please LennyPlayzYT 269 — 4y
0
yeah kinda new to this, edited Grammar_Iy 8 — 4y
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 ItzSulfonic 61 — 4y
0
yeah was that not it? thats server side Grammar_Iy 8 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
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)

Answer this question