local commands = {}
local booleans = script:WaitForChild("Booleans")
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local prefix = "!"
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message, content)
message = string.lower(message)
local splitMessage = message:split(" ")
local prefixCommand = splitMessage[1]
local splitCommand = prefixCommand:split(prefix)
local getCommand = splitCommand[2]
if commands[getCommand] then
commands[getCommand]()
end
end)
end)
--//Commands
commands.ShowCollision = function()
print("help")
end
Did you include into your testing, that game.Players.PlayerAdded will only work on other players and not the client itsself? So it cant detect with that method if the local plr itsself chatted
local commands = {}
local booleans = script:WaitForChild("Booleans")
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local prefix = "!"
player.Chatted:Connect(function(message, content)
message = string.lower(message)
local splitMessage = message:split(" ")
local prefixCommand = splitMessage[1]
local splitCommand = prefixCommand:split(prefix)
local getCommand = splitCommand[2]
if commands[getCommand] then
commands[getCommand]()
end
end)
--//Commands
commands.ShowCollision = function()
print("help")
end
The problem is that you are binding the chatted event after a new player joins. This means that it won’t work until a new player joins.
Since you already have the player variable listed at the top, the playerAdded event is not necessary.