So I have this script that is supposed to print “EEEEEEEEEEEEEEEEEEE” when you say “e” in chat (Yes I know it’s pretty stupid),
but it does nothing.
Here is the script:
local Players = game:GetService("Players")
--options
local option1 = "e"
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message:lower() == option1:lower() then
print("EEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
end
end)
end)
local Players = game:GetService("Players")
--options
local option1 = "e"
for _,player in Players:GetPlayers() do
player.Chatted:Connect(function(message)
if message:lower() == option1:lower() then
print("EEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
end
end)
end
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message:lower() == option1:lower() then
print("EEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
end
end)
end)
edit explanation:
so, the script didn’t work at first because it ran after the player joined the game
to fix this we loop through all players at the start
and a better way than my previous example would be using a function
for _,player in Players:GetPlayers() do
playerAdded(player)
end
Players.PlayerAdded:Connect(playerAdded)
function playerAdded(player)
player.Chatted:Connect(function(message)
if message:lower() == option1:lower() then
print("EEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
end
end)
end