Hello developers. So I’ve been trying to make a F1 marshall light system, which starts a function when a specific chat is sent. Everything was working correctly, until I’ve started creating the functions themself.
Basically my code was a print after detected specific message, but now I wanted to replace it with functions. Got the “Invalid argument #1 to ‘lower’ (string expected got function)” error.
This is 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
local PlayersService = game:GetService("Players");
-- FUNCTIONS
local function GreenFlag()
script.Parent.Screen.BrickColor = BrickColor.new("Lime green")
end;
local function YellowFlag()
wait(1.5)
script.Parent.Screen.BrickColor = BrickColor.new("Bright yellow")
wait(1.5)
script.Parent.Screen.BrickColor = BrickColor.new("Really black")
end;
local function RedFlag()
wait(1)
script.Parent.Screen.BrickColor = BrickColor.new("Really blue")
wait(1)
script.Parent.Screen.BrickColor = BrickColor.new("Really black")
end;
--
PlayersService.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if string.find(string.lower(Message), string.lower(GreenFlag)) then
print("GreenFlag")
GreenFlag()
elseif string.find(string.lower(Message), string.lower(YellowFlag)) then
print("YellowFlag")
YellowFlag()
elseif string.find(string.lower(Message), string.lower(RedFlag)) then
print("RedFlag")
RedFlag()
elseif string.find(string.lower(Message), string.lower(VirtualSafetyCar)) then
print("VSC")
elseif string.find(string.lower(Message), string.lower(SafetyCar)) then
print("SC")
end;
end);
end);
Let me know if anything is unclear.