This script is supposed to detect if a player is one of the usernames mentioned in a table. If the player is that username, they can move maps from ServerStorage into Workspace. However, the script isn't working, and I have no idea why, since output gave me nothing.
Can someone please help me?
Here's the script:
current_map = nil
names = {"CoolJohnnyboy","Player1"}
game.Players.PlayerAdded:connect(function(player)
for i, v in pairs(names) do
if v == player.Name then
player.Chatted:connect(function(chatmsg)
if chatmsg:sub(1,6) == "!load/" then
local map = chatmsg:sub(7, chatmsg:len())
if game.Lighting:FindFirstChild(map) then
local mapp = game.ServerStorage.Maps:FindFirstChild("Urban"):Clone()
if current_map ~= nil then
game.Workspace[current_map]:Destroy()
end
mapp.Parent = game.Workspace
current_map = mapp.Name
end
end
end)
end
end
end)

4 comments
Put a print right before player.Chatted, and tell me if it prints
I did that, did not print anything.
Comment the if statement and try again. The problem could be there.
Obviously you will need it but to see if that is what is causing the problem...