So, I've been trying to do chat commands and stuff, but when you say the command word in a sentence it doesn't activate. I THINK you have to use :match() for this? I don't know, so could anyone help me out? Here's the test code:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() player.Chatted:Connect(function(message) if message:lower() == "lumos" then game.ReplicatedStorage.LumosEvent:FireServer(mouse.Hit.p) end end)
You can use string.sub,string.match, or string.find, most likely string.match or string.find
local player = game.Players.LocalPlayer local mouse = player:GetMouse() player.Chatted:Connect(function(message) if (message:lower()):match('lumos') then game.ReplicatedStorage.LumosEvent:FireServer(mouse.Hit.p) end end)
You can use the message argument.
local player = game.Players.LocalPlayer local mouse = player:GetMouse() player.Chatted:connect(function(msg) if msg = string.lower("lumos") then game:GetService("ReplicatedStorage").LumosEvent:FireServer(mouse.Hit.p) end end)