Hello developers! So, I made this already “kinda” working script for my Electronic Marshall System. However, the functions kinda overlay each other… By that I mean: Example of what is happening. Basically, I need to know how to “stop” other functions from running after 1 other starts. By that, I mean for example: I start the “SC_DEP” function, then the “YellowFlagDEP” function. I know that I can use return but I have no idea where and how. Also, I use the repeat until false which won’t really be a big problem after other functions stop, I belive. So yeah, If anyone could just tell me how to stop every other function after starting a new one. (By the way you start functions by chatting a specific message)
My code:
-- SETTINGS
local GreenFlag = "Green_Flag"; -- Message that sets the flag to Green.
local YellowFlag = "Yellow_Flag"; -- Message that sets the flag to Yellow.
local RedFlag = "Red_Flag"; -- Message that sets the flag to Red.
local VirtualSafetyCar = "VSC"; -- Message that sets the screen to VSC.
local SafetyCar = "SC"; -- Message that sets the screen to SC.
-- LOCALS
stop = false
local PlayersService = game:GetService("Players");
-- FUNCTIONS
local function GreenFlagDEP()
script.Parent.Screen.VSC.Enabled = false
script.Parent.Screen.SC.Enabled = false
script.Parent.Screen.BrickColor = BrickColor.new("Lime green")
end;
local function YellowFlagDEP()
script.Parent.Screen.VSC.Enabled = false
script.Parent.Screen.SC.Enabled = false
repeat
wait(0.35)
script.Parent.Screen.BrickColor = BrickColor.new("Bright yellow")
wait(0.35)
script.Parent.Screen.BrickColor = BrickColor.new("Really black")
until false
end;
local function RedFlagDEP()
script.Parent.Screen.VSC.Enabled = false
script.Parent.Screen.SC.Enabled = false
repeat
wait(0.35)
script.Parent.Screen.BrickColor = BrickColor.new("Really red")
wait(0.35)
script.Parent.Screen.BrickColor = BrickColor.new("Really black")
until false
end;
local function VSC_DEP()
script.Parent.Screen.BrickColor = BrickColor.new("Really black")
script.Parent.Screen.VSC.Enabled = true
script.Parent.Screen.SC.Enabled = false
repeat
wait(0.35)
script.Parent.Screen.Orange.Transparency = 0.35
wait(0.35)
script.Parent.Screen.Orange.Transparency = 1
until false
end;
local function SC_DEP()
script.Parent.Screen.BrickColor = BrickColor.new("Really black")
script.Parent.Screen.VSC.Enabled = false
script.Parent.Screen.SC.Enabled = true
repeat
wait(0.35)
script.Parent.Screen.Orange.Transparency = 0.35
wait(0.35)
script.Parent.Screen.Orange.Transparency = 1
until false
end;
--
PlayersService.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if string.find(string.lower(Message), string.lower(GreenFlag)) then
print("GreenFlag")
GreenFlagDEP()
elseif string.find(string.lower(Message), string.lower(YellowFlag)) then
print("YellowFlag")
YellowFlagDEP()
elseif string.find(string.lower(Message), string.lower(RedFlag)) then
print("RedFlag")
RedFlagDEP()
elseif string.find(string.lower(Message), string.lower(VirtualSafetyCar)) then
print("VSC")
VSC_DEP()
elseif string.find(string.lower(Message), string.lower(SafetyCar)) then
SC_DEP()
print("SC")
end;
end);
end);
If anything is unclear, please let me know.