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
What happens is the program loops continually and never ends now if it had wait() function atleast it can stop the program for that time before it loops again.
You should add wait in after repeat.
if userOnFire then repeat user:TakeDamage(5) wait(0.1) --is 10% of on second until userHP <= 0 else print("I am not on fire!") -- Even without this line, the game freezes. end