Usually when spawning into a game, the player character is automatically given a Health script. This script is a small script that heals the player by 1/100th of their health every second, updating when the player takes damage. However, in one game I’m working on the game simply doesn’t give the player this script. Even stranger than that is when I copy the Health script from a game that does automatically spawn it in and place it in StarterCharacterScripts, the script does appear in the character when spawned in but doesn’t do anything. Any help?
For context, here’s the health script that is automatically generated in all other experiences. I know it’s automatic since it works like this in another game I’ve made with zero models from the toolbox so I know it’s not from a free model or anything I’ve been using.
-- 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 = task.wait(REGEN_STEP)
local dh = dt*REGEN_RATE*Humanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
end
Humanoid.HealthChanged:Wait()
end