Hello!
I want to make a script for the health of models, but I don’t know how (since I recently started learning scripting) how to make a script.Can you help me create this script?
Thanks in advance!
Hello!
I want to make a script for the health of models, but I don’t know how (since I recently started learning scripting) how to make a script.Can you help me create this script?
Thanks in advance!
Every Character has a Humanoid inside of it. The Humanoid has a Health property which you can change.
Humanoid | Documentation - Roblox Creator Hub
local Player = -- Location of the player
local Humanoid = Player.Character:FindFirstChildWhichIsA("Humanoid")
Humanoid.Health = 0 -- Kills the player
If you meant to regenerate health, you can make a (Server) Script inside the Model named “Health”.
Code:
-- Gradually regenerates the Humanoid's Health over time.
local REGEN_RATE = 1/100 -- Regenerate this fraction of MaxHealth per second.
local REGEN_STEP = 1 -- Wait this long between each regeneration step.
--------------------------------------------------------------------------------
local Character = script.Parent
local Humanoid = Character:WaitForChild'Humanoid'
--------------------------------------------------------------------------------
while true do
while Humanoid.Health < Humanoid.MaxHealth do
local dt = wait(REGEN_STEP)
local dh = dt*REGEN_RATE*Humanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
end
Humanoid.HealthChanged:Wait()
end
Hello! Please note that Scripting Support isn’t a place to ask for people to write you scripts. You need to try to make it yourself first. You can maybe watch a video on the basics of lua or read some Roblox documentations.
Yes, okay. I worked as a builder for 2 years, but I never heard about documentation and forum. Thanks, now I will be informed.
Thank you. For your help in the creation script! ![]()
Thank you. For your help in the creation script. ![]()
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.