Fire System
Ever wanted to know how to create a fire spawning system? You’ve come to the right place!
This is a beginner’s system. Basic knowledge of LUA is suggested.
First, I want to clarify what I mean by a ‘fire spawning system’. A fire spawning system is essentially a system that will automatically spawn a fire depending on the scale of members on a team.
What would this system work great with?
This system would work best with RolePlay (RP) games that have a Fire Department team!
Let’s Get Started
- First, create a folder and name it whatever you’d like. This will be your
HostingFolder
- Now that you’ve created a folder, add 2 folders inside of it. One of them should be the folder containing models for your
SmallFires
and one containing models for yourLargeFires
. - Inside your main folder, add a
BoolValue
called FireEnabled - Add your models to the large or small fire folder
- Inside your model, select parts you would like to set fire and name it the same name you will set your variable (see variables below)
- Inside these part(s) you must add fire and smoke to it. Adjust these settings as you wish
- Create a ServerScript in
ServerScriptService
and copy these variables
_G.FireFolder = workspace.FireBuilds
_G.LargeFireFolder = _G.FireFolder.LargeFires
_G.SmallFireFolder = _G.FireFolder.SmallFires
_G.FireTime = 5 -- in seconds; the amount of time to wait to initiate a fire
local fire_folder = _G.FireFolder
local fire_time = _G.FireTime
local small_amount = 1 -- amount of players for a small fire
local large_amount = 8 -- amount of players for a large fire
local fire_part_name = "FireSource" -- name of your part(s) that will have fires on them
local fire_department = game.Teams.FD
Now that you have inserted your variables, we will need to begin scripting the actual system.
I decided to use the while wait()
function (some may have preferred a different way, however, this is the most simplistic way in my opinion). Begin by declaring the function
while wait(fire_time) do
end
Inside your while
function, add this:
if _G.FireFolder:FindFirstChild("FireEnabled") then
if _G.FireFolder.FireEnabled.Value == true then
return
else
if #fire_department:GetPlayers() >= small_amount and #fire_department:GetPlayers() < large_amount then
if _G.SmallFireFolder:IsA("Folder") then
local gc = _G.SmallFireFolder:GetChildren()
local chosen_fireplace = gc[math.random(1, #gc)]
for _,part in next, chosen_fireplace:GetChildren() do
if part:IsA("Part") then
if part.Name == fire_part_name then
if part:FindFirstChild("Fire") and part:FindFirstChild("Smoke") then
part.Fire.Enabled = true
part.Smoke.Enabled = true
_G.FireFolder.FireEnabled.Value = true
end
end
end
end
end
elseif #fire_department:GetPlayers() >= large_amount then
if _G.LargeFireFolder:IsA("Folder") then
local gc = _G.LargeFireFolder:GetChildren()
local chosen_fireplace = gc[math.random(1, #gc)]
for _,part in next, chosen_fireplace:GetChildren() do
if part:IsA("Part") then
if part.Name == fire_part_name then
if part:FindFirstChild("Fire") and part:FindFirstChild("Smoke") then
part.Fire.Enabled = true
part.Smoke.Enabled = true
_G.FireFolder.FireEnabled.Value = true
end
end
end
end
end
end
end
else
print("Could not find the 'FireEnabled' BoolValue")
end
Now, to break down what this code does:
if _G.FireFolder:FindFirstChild("FireEnabled") then
if _G.FireFolder.FireEnabled.Value == true then
this checks for the FireEnabled
BoolValue we added earlier. This is what tells the script whether or not there is already a fire.
if #fire_department:GetPlayers() >= small_amount and #fire_department:GetPlayers() < large_amount
-- and
elseif #fire_department:GetPlayers() >= large_amount
this tells the script whether or not there is a quorum of members on the team adding up to the LargeFire
amount or SmallFire
amount.
The rest of the script finds a random model to spawn a fire and sets all the parts named fire_part_name
on fire.
I have not yet added a system to remove spawned fires or a command to start fires. If there is a high demand for it, I might add an update to this for you.
If you are too lazy to read through the above, you can just get the model on Roblox and customize it from there (I am not adding a step-by-step on how to do this. You can read through this post to find out). Fire System (Public) - Roblox
=* Global variables were used since i was going to make a second addition, but decided not to (and I wanted to keep it simple [beginners level])