Skip to main content

Display on panels

info

This is optional

Let's say you also want to display when the fire is going to get turned on or off on the panels. To do that we need to use the Panels module:

local panels = require(workspace.StacyPilot.Panels)

Then we need to create a new track on the panels, in this example the track will be indicated by a fire emoji. It'll also have a brownish background, be placed below the separator and will scroll automatically

local track = panels:AddTrack("🔥", Color3.fromRGB(97, 65, 0), 1, true)

Now we will listen for when a replay starts, when it does, we will filter out the data so we only have data for the fire

core.Events.PlaybackStarted:Connect(function(data)
data = core:FilterData(data, "Fire")
...

Next we will transform the data a bit, we will only show the line when the fire is on and we will give the lines a slightly green background

	...
local transformedData = {}
for i, fireData in data do
if fireData.Data[1] == "On" then
local nextData = next(data, i)
local duration = if data[nextData] then data[nextData].Time - fireData.Time else 2
table.insert(transformedData, {
Duration = duration,
Text = fireData.Data[1],
Time = fireData.Time,
BackgroundColor = Color3.fromRGB(0, 113, 26)
})
end
end
...

Finally, we'll tell the panels to display that data

	...
track:PopulateWithData(transformedData)
end)

And now we will be able to see when the fire turns on and off. Full code:

local core = require(workspace.StacyPilot.Core)
local panels = require(workspace.StacyPilot.Panels)
local pyroFolder = workspace.Fire
local clickDetector = script.Parent.ClickDetector
local track = panels:AddTrack("🔥", Color3.fromRGB(97, 65, 0), 1, true)

local function turnOn()
for _, part in pyroFolder:GetChildren() do
part.ParticleEmitter.Enabled = true
end
end

local function turnOff()
for _, part in pyroFolder:GetChildren() do
part.ParticleEmitter.Enabled = false
end
end

clickDetector.MouseClick:Connect(function()
turnOn()
core:Record("Fire", "On")
end)

clickDetector.RightMouseClick:Connect(function()
turnOff()
core:Record("Fire", "Off")
end)

core:RegisterResponse("Fire", function(data)
local actionName = data[1]

if actionName == "On" then
turnOn()
elseif actionName == "Off" then
turnOff()
end
end)

core.Events.PlaybackStarted:Connect(function(data)
data = core:FilterData(data, "Fire")
local transformedData = {}
for i, fireData in data do
if fireData.Data[1] == "On" then
local nextData = next(data, i)
local duration = if data[nextData] then data[nextData].Time - fireData.Time else 2
table.insert(transformedData, {
Duration = duration,
Text = fireData.Data[1],
Time = fireData.Time,
BackgroundColor = Color3.fromRGB(0, 113, 26)
})
end
end
track:PopulateWithData(transformedData)
end)