Script Planning Help

Hello,

I’ve been working on a little something in my spare time, that works- but not in a way I hope to make it. And you’re probably wondering what it is exactly that I’m making? Well here is a quick video:

So what you saw there was my take on a Formula 1 flag system, and if you don’t know what I’m talking about then you can have a look at this.

Anyway, the end goal is for me to use that interface to control a specific group of flags on the game, and also to display different types of flags on a single flag. But the thing I can’t work out, is how I am going to display each flag, as some flag designs use more than one part, and others just use the one.

Now here are my questions:

  1. I’m currently using GetTagged to select parts to display the flag on. Is there a better way of doing it? And also I’d like to be able to target specific groups of flags in the game to display flag types, so is this a future proof way?

  2. How can I display the different flag types? Eg… the Safety Car one, which will have a flashing part, and a solid colour part. But also have the ability to show the single flashing part which is the green, yellow, blue, etc… that you saw in the video. Could I use module scripts or something along those lines?

So if my second question doesn’t make sense, I’d like to make the SC flag etc… all displayable in one part:
image

Server code
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local EventFolder = ReplicatedStorage.Events.FlagSystem
local FlagEvent = EventFolder.FlagEvent

local Flags = CollectionService:GetTagged("Flag")
local Current = BrickColor.Black()

FlagEvent.OnServerEvent:Connect(function(Player, Colour)
	if not typeof(Colour) == BrickColor then
		return
	else
		Current = Colour 
	end
end)

local function setColor(Colour)
	for _, Part in pairs(Flags) do 
		Part.BrickColor = Colour
	end
end

while true do 
	setColor(Current)
	wait(0.25)
	setColor(BrickColor.Black()) 
	wait(0.25)
end
Code used in each button on the UI
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local EventFolder = ReplicatedStorage.Events.FlagSystem
local FlagEvent = EventFolder.FlagEvent

script.Parent.MouseButton1Click:Connect(function()
	FlagEvent:FireServer(BrickColor.Blue())
end)

If you still don’t understand what I am trying to do, please ask me any questions below.

Thanks

1 Like

So to address your questions i’ll do it in the order you asked…

  1. For the first question regarding how to control a selected group of flags, i’m going to use the same approach that many of us in the roblox lighting community utilize. This is known as creating a patch system. Whilst CollectionService would work for this I don’t love using it, and i like having a more solid and specific system devoted to doing this.
  • How the patch system works essentially is through having a group of all of the potential fixtures or in your case flags in formula 1, and giving each of them some kind of unique identifier to distinguish one another from eachother. It could be as simple as giving them a number starting at 0 and adding 1 onto the next, so on and so forth. From there you have some kind of button (for every flag or group of flags) that adds the corresponding flag(s) to a table. From there with your controller your controller will be responsible for controlling the currently selected flags. When you want to remove those flags from a table you just make it so when you turn off the button or whatever that selects it, you have it remove those flags from the table. Hopefully that wasn’t too complicated.
  1. For the second question, even though it was somewhat hard to understand specifically what your asking. I’m assuming you wanted to be able to create one group that would be able to display every different light pattern on the controller. For this you could just make a surfacegui or just a part that cycles through visibilities with hardcoded patterns somewhat similar to how a seven segment display is programmed. Otherwise using a surfacegui would be your best bet since you can separate things into different frames and it’s cleaner but it’s understandable if you still want the neon hue.

Hopefully that gives you some insight.

2 Likes

Thanks for the reply, this helped a lot!

1 Like

Hello again,

I ended up making GUI’s for each flag as you suggested.

This make’s it much easier to program, and is probably just a better idea overall. But the only questions I have now are:

  1. How would you suggest I add the GUI’s to the selected flag parts
  2. Due to the flags needing to flash differently, and at different timings, how would you suggest I manage this?
  3. How should the flashing of the flags be handled? All from the server? Or should a script be sent to each individual GUI to manage the flash? (Basically question 2 I guess).

Thanks

Would adding a script to all of the flag parts work? That all listen for an event to be fired and clone a flag from a storage folder or something and parent it to itself?

Ah! I’ve also created such a system a few weeks ago.

Looks pretty good, however I’d recommend you making the colors a little less bright. Most of them looks kinda “cartoony” ?; imo. The irl flags are solid base colors (ex. Really Red) and your is like “whiteish” if I can say it like this. The colors should look more like this:
image

Besides, I don’t think the white flag is shown on electronic flag panels (may be wrong).

Cool.

  1. IRL, the electronic flag panels are separated for sectors (~13). So, you could just make stands for each flag panel. Or better option - you could make a room somewhere on the restricted place on the track and just make a gui when you select the choosen sector (from ~13 sectors) and it would let you choose a flag separately for each one. The first option is more realistic, it’s pretty unefficient and the second of is unrealistic but it’s efficient. (I just used chat message system which appears to be kinda efficient.)

  2. You could just set different flash timings for each flag. Use this as some reference for timing.

  3. Look point 1.

Thanks for the reply- all the flags I made were shown in the video you linked, as I happened to also see it lol. I did my best to use the same timings as shown in the video, and I believe I am pretty close (I think all of them use the same timings apart from double yellow). Also the flags look a little cartoony because of the lighting I believe.

I also edited the colours yesterday or so as I was also not satisfied with the look lol. Here’s my finished set:

If you’d like to see in game, here’s the link: Formula 0.1 - Roblox