Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Why won't this fire script work?

Asked by 9 years ago

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:

01function loseHealth(part)
02    print("Gotta set this part on fire!")
03    print(part.Name)
04    fire = Instance.new("Fire")
05    fire.Parent = part
06    --Now losing health...
07    for i = 100, 0, -1 do
08        wait(0.1)
09        part.Parent.Humanoid.Health = i
10    end
11end

Most of this is in the wiki, so why isn't this right?

0
What isn't right about it? Is there an error? Does the script not run? ClassicTheBlue 65 — 9y
0
Oh wow, you're back. I actually haven't tested it, but I still don't believe it works. NeonicPlasma 181 — 9y
0
Try using this script in a brick with the Touched event. I forgot to put that on. NeonicPlasma 181 — 9y
0
Oh and also, I have some feedback to your game. You could hide secret codes in the lobby and when they enter one of the correct codes they get something to help them on the course. That is what I am working on. NeonicPlasma 181 — 9y

1 answer

Log in to vote
5
Answered by 9 years ago
  1. You forgot to hook up the function to an event
  2. Your code can run multiple times simultaneously
  3. The function might run on something that's not a player, thus breaking it entirely.
01local burning = { }
02 
03function burnPlayer(player)
04    -- If the player is already burning, then stop the function.
05    if burning[player] then
06        return
07    end
08 
09    -- Set that the player is burning in our table, using the player object as an index.
10    burning[player] = true
11 
12    -- Create the fire in the character's head.
13    Instance.new("Fire", player.Character.Head)
14 
15    -- Set a variable to the Humanoid for easy reference.
View all 44 lines...
Ad

Answer this question