I'm extremely new to scripting. I've been messing around and challenging myself to script certain stuff. Below is the code block, and I've commented on the block that freezes the game.
It's also an edited version of the fire tutorial on the wiki.
wait(1) -- Waits for player to load in.
-- Variables for the lava, users, user HP, and checking to see if player has touched lava.
local Lava = game.Workspace.Lava1
local user = game.Players.LocalPlayer.Character.Humanoid
local userHP = game.Players.LocalPlayer.Character.Humanoid.Health
local userOnFire = Lava.Touched
-- Function that creates the fire effect.
function lightOnFire(part)
print("Going to light this part on fire:")
print(part.Name)
local fire = Instance.new("Fire")
fire.Parent = part
end
userOnFire:connect(lightOnFire) --calls upon function
-- The below code is freezing the game when I attempt to load in.
if userOnFire then
repeat
user:TakeDamage(5)
until
userHP <= 0
else
print("I am not on fire!") -- Even without this line, the game freezes.
end

1 comment
Thanks for answering! Now, the same block isn't working how I'd like. If you think you can fix it, I've posted another question thread here: https://scriptinghelpers.org/questions/59412/why-does-this-script-damage-me-easy-for-experienced