Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Chat not case sensative?

Asked by 8 years ago

I created 2 scripts using chat messages, but they are case sensative, I wanted to know how the heck I would make it not case sensative for future scripts as well as to fix these 2.

admin = { "Flavoured","conman0552","EPICBRO2004","Ramerion","Skylord170" }
game.Players.PlayerAdded:connect(function(nP)
for _,v in pairs(admin) do
if nP.Name == v then
nP.Chatted:connect(function(msg)
if msg == "close/Bricktops" then
local x = game.Workspace.Bricktops:Destroy()
wait()
end
end)
end
end
end)


admin = {"Flavoured","conman0552","EPICBRO2004","Ramerion","Skylord170" }

game.Players.PlayerAdded:connect(function(nP)
for _,v in pairs(admin) do
if nP.Name == v then
nP.Chatted:connect(function(msg)
if msg == "start/Bricktops" then
local x = game.Lighting.Bricktops:Clone()
x.Parent = game.Workspace
end
end)
end
end
end)

1 answer

Log in to vote
2
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

You can achieve this using string.upper() or string.lower(). Personally, I prefer using string.lower(). Also, you can condense these 2 scripts into one if you'd like, since their contents are alike.

admin = { "Flavoured","conman0552","EPICBRO2004","Ramerion","Skylord170" }
game.Players.PlayerAdded:connect(function(nP)
    for _,v in pairs(admin) do
        if nP.Name == v then
            nP.Chatted:connect(function(msg)
                if string.lower(msg) == "close/bricktops" then -- Converts the message to all lowercase, and then compares it to an all lowercase string.
                    if game.Workspace:FindFirstChild('Bricktops') then
                        game.Workspace.Bricktops:Destroy()
                        wait()
                    end
                elseif string.lower(msg) == "start/bricktops" then -- Does the same.
                    game.Lighting.Bricktops:Clone().Parent = game.Workspace
                end
            end)
        end
    end
end)

Hope this helped.

Ad

Answer this question