Anybody know why this isn’t working, nothing is happening
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
local message = msg:lower()
if message:match("/id") then
local splitMessage = message:split(" ")
print(splitMessage)
if splitMessage == nil then
local clone = game.ReplicatedStorage.ID:Clone()
clone.Parent = player.PlayerGui
end
if splitMessage ~= nil then
if game.Players:FindFirstChild(splitMessage) then
local clone = game.ReplicatedStorage.ID:Clone()
clone.Parent = player.PlayerGui
else
return("No Player Found!")
end
end
end
end
end)
end)
Some of the ends might not be correct as I had to edit some of the code for privacy reasons, aswell as the formating might be incorrect. I apologize.
no, doing lower won’t affect this. Using string.split and string.find would work better at the start. Like this:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
local splitmsg = msg:split(" ")
splitmsg[1] = splitmsg[1]:lower()
if splitmsg[1] == "/id" then
if splitmsg[2] == nil then
local clone = game.ReplicatedStorage.ID:Clone()
clone.Parent = player.PlayerGui
end
if splitmsg[2] ~= nil then
if game.Players:FindFirstChild(splitmsg[2]) then
local clone = game.ReplicatedStorage.ID:Clone()
clone.Parent = player.PlayerGui
else
return("No Player Found!")
end
end
end
end
end)
end)