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

Multiple people & spawn command cleaning, help?

Asked by
Lopous 1
7 years ago

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)

01game.Players.ChildAdded:connect(function(player)
02player.Chatted:connect(function(chat)
03if player.Name == "Lopous" then --Change your name with mine.
04if 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.
05if not game.Workspace:FindFirstChild("KoTHB") then --Change "KoTHB" to your map's name.
06game.Lighting["KoTHB"]:Clone().Parent = game.Workspace --Change "KoTHB" to your map's name.
07end
08elseif string.lower(chat) == ";close KoTHB" then --This is the same, just removes the map.
09if game.Workspace:FindFirstChild("KoTHB") then
10game.Workspace["KoTHB"]:Remove()
11end
12end
13end
14end)
15end)--Made By Lopous
16--You can't add more people. o3o

1 answer

Log in to vote
0
Answered by
DevNetx 250 Moderation Voter
7 years ago
Edited 7 years ago

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.

01-- define a list of players we want to be allowed to use the command
02local authorized = {
03    ['Lopous'] = true,
04    ['SystemUnderflow = true,
05    -- etc
06}
07 
08-- define map - change this
09local map = "KoTHB"
10 
11game.Players.ChildAdded:connect(function(player)
12    player.Chatted:connect(function(chat)
13        if authorized[player.Name] then --Change your name with mine.
14            if string.lower(chat) == ";open ".. map then
15                if not game.Workspace:FindFirstChild(map) then
View all 25 lines...
0
Thanks. Again, this is an old script that I made. Lopous 1 — 7y
Ad

Answer this question