This is supposed to make the player turn on fire and they will start losing health. But this fire script won't work. This script is in a brick:
function loseHealth(part) print("Gotta set this part on fire!") print(part.Name) fire = Instance.new("Fire") fire.Parent = part --Now losing health... for i = 100, 0, -1 do wait(0.1) part.Parent.Humanoid.Health = i end end
Most of this is in the wiki, so why isn't this right?
local burning = { } function burnPlayer(player) -- If the player is already burning, then stop the function. if burning[player] then return end -- Set that the player is burning in our table, using the player object as an index. burning[player] = true -- Create the fire in the character's head. Instance.new("Fire", player.Character.Head) -- Set a variable to the Humanoid for easy reference. local Humanoid = player.Character.Humanoid -- Slowly remove player's health. for i = 100, 0, -1 do wait(0.1) Humanoid.Health = i end -- Make sure the player actually dies. player.Character:BreakJoints() -- Remove the player key from the table, so he can touch it again and burn to death after he respawns. burning[player] = nil end function PartTouched(part) -- Get the Player object from the character. If the part's parent isn't a character, this will be nil. local player = game.Players:playerFromCharacter(part.Parent) -- Check if player is nil. If it is, stop the function. if not player then return end -- Moving the burn player code into another function. burnPlayer(player) end script.Parent.Touched:connect(PartTouched)