So this is an old script of mine, that I made ages ago. I want it to look cleaner and I want be able to make so multiple people can join instead of just me and I'm able to spawn more than just one model. It's fine with just one model, but y'know what I mean (I hope)
game.Players.ChildAdded:connect(function(player) player.Chatted:connect(function(chat) if player.Name == "Lopous" then --Change your name with mine. if string.lower(chat) == ";open KoTHB" then --Feel free to change how you open the map, but I recommend you to not. That you can do is change "KoTHB" with your map. if not game.Workspace:FindFirstChild("KoTHB") then --Change "KoTHB" to your map's name. game.Lighting["KoTHB"]:Clone().Parent = game.Workspace --Change "KoTHB" to your map's name. end elseif string.lower(chat) == ";close KoTHB" then --This is the same, just removes the map. if game.Workspace:FindFirstChild("KoTHB") then game.Workspace["KoTHB"]:Remove() end end end end) end)--Made By Lopous --You can't add more people. o3o
The best way to do this is by using dictionaries.
I've also cleaned up your map name - it's not a good idea to define the same thing over and over again. If it's only stored in one variable, you only have to change that text.
-- define a list of players we want to be allowed to use the command local authorized = { ['Lopous'] = true, ['SystemUnderflow = true, -- etc } -- define map - change this local map = "KoTHB" game.Players.ChildAdded:connect(function(player) player.Chatted:connect(function(chat) if authorized[player.Name] then --Change your name with mine. if string.lower(chat) == ";open ".. map then if not game.Workspace:FindFirstChild(map) then game.Lighting[map]:Clone().Parent = game.Workspace end elseif string.lower(chat) == ";close ".. map then if game.Workspace:FindFirstChild(map) then game.Workspace[map]:Remove() end end end end) end)