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

clearly my title isnt specific enough so heres a random title?

Asked by 6 years ago
Edited 6 years ago
mapactive = nil
admins = {"HydroDivinity"}


game.Players.PlayerAdded:connect(function(player)
    for _,v in pairs(admins) do
        if v == player.Name then
            player.Chatted:connect(function(msg)
                if msg:sub(1,5) == "load/" then
                    local map = msg:sub(5,msg:len())
                    if game.ServerStorage:FindFirstChild(map) then
                        if map ~= nil then
                            map.Parent = game.ServerStorage
                        end
                        game.ServerStorage[map].Parent = game.Workspace
                        map = game.Workspace[map]
                    end
                end
            end)
        end
    end
end)

This is what I have so far. Trying to create a holo-loader

1
Then edit your question. Also you need to include a meaningful title and some description to explain what you are trying to do. User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by
luadotorg 194
6 years ago

Next time you do a question, please give it atleast a title and a description that explains what you're trying to do and what is wrong.

Either ways, I understood what you meant. You did something that most people do when learning Lua, and you are off with a good start.

You are trying to move the model from ServerStorage to Workspace if I'm not wrong, but you only used .Parent. This is your problem. You forgot that after using it once, it won't be able to clone anymore because it won't be parented to ServerStorage anymore.

Here's your fix: :Clone().

Also, besides this, your only issue was that you failed some logics. If your model is in workspace, it won't check according to your code, which gives your issue.

mapactive = nil
admins = {"HydroDivinity"}

game.Players.PlayerAdded:connect(function(player)
    for _,v in pairs(admins) do
        if v == player.Name then
            player.Chatted:connect(function(msg)
                if msg:sub(1,5) == "load/" then
                    local map = msg:sub(5,msg:len())
                    if game.ServerStorage:FindFirstChild(map) or workspace:FindFirstChild(map) then
                        if map ~= nil then
                            map.Parent = game.ServerStorage
                        end
                        game.ServerStorage[map]:Clone().Parent = game.Workspace
                        map = game.Workspace[map]
                    end
                end
            end)
        end
    end
end)

Hope this helps you!

Ad

Answer this question