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

My plugin isn't creating any models or parts even though I think I did everything correctly?

Asked by 3 years ago

I am currently working on a plugin BUT the script wont do anything except make toolbar buttons

local mouse = plugin:GetMouse()
local ChangeHistoryService = game:GetService("ChangeHistoryService")

local toolbar = plugin:CreateToolbar("Better Building Tools")
local putInFolder = toolbar:CreateButton("Put selected objects in a folder", "Put selected objects in a folder", "rbxassetid://4459262762")
local betterSpawnLocation = toolbar:CreateButton("Better Looking Spawn", "Create a new spawn", "rbxasset://textures/SpawnLocation.png")
local newConveyor = toolbar:CreateButton("Conveyor", "Create a conveyor", "rbxassetid://6309194705")
local killBrick = toolbar:CreateButton("Kill Brick", "Create a Kill Brick", "rbxassetid://6309194705")

putInFolder.Click:Connect(createFolder())
betterSpawnLocation.Click:Connect(createSpawn())
newConveyor.Click:Connect(createConveyor())
killBrick.Click:Connect(createKillBrick())

function createFolder()
    local newKill = script.KillBrick:Clone()
    newKill.Parent = game.Workspace
    ChangeHistoryService:SetWaypoint("new kill brick")
end

function createKillBrick()
    local mouse = plugin:GetMouse()
    local ChangeHistoryService = game:GetService("ChangeHistoryService")
    local newKill = script.KillBrick:Clone()
    newKill.Parent = game.Workspace
    ChangeHistoryService:SetWaypoint("new kill brick")
end

function createConveyor()
    return function()
        --Converted with ttyyuu12345's model to script plugin v4
        local function sandbox(var,func)
            local env = getfenv(func)
            local newenv = setmetatable({},{
                __index = function(self,k)
                    if k=="script" then
                        return var
                    else
                        return env[k]
                    end
                end,
            })
            setfenv(func,newenv)
            return func
        end
        cors = {}
        mas = Instance.new("Model",game:GetService("Lighting"))
        model = Instance.new("Model")
        model.Name = "Conveyor"
        model.Parent = mas
        Part0 = Instance.new("Part")
        Script1 = Instance.new("Script")
        UnionOperation2 = Instance.new("UnionOperation")
        Part0.Name = "Conveyor"
        Part0.Parent = model
        Part0.CFrame = CFrame.new(22, 0.5, -81, 1, 0, 0, 0, 1, 0, 0, 0, 1)
        Part0.Position = Vector3.new(22, 0.5, -81)
        Part0.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
        Part0.Size = Vector3.new(4, 1, 6)
        Part0.Anchored = true
        Part0.BottomSurface = Enum.SurfaceType.Smooth
        Part0.BrickColor = BrickColor.new("Really black")
        Part0.FrontSurface = Enum.SurfaceType.Weld
        Part0.TopSurface = Enum.SurfaceType.Smooth
        Part0.brickColor = BrickColor.new("Really black")
        Script1.Name = "ConveyorScript"
        Script1.Parent = Part0
        table.insert(cors,sandbox(Script1,function()
            local speed = 10
            while wait() do
                script.Parent.Velocity = script.Parent.CFrame.LookVector * speed
            end
        end))
        UnionOperation2.Archivable = false
        UnionOperation2.Parent = model
        UnionOperation2.archivable = false
        UnionOperation2.CFrame = CFrame.new(22.0826416, 1.125, -81.2719879, 0.707106769, 0, 0.707106769, 0, 1, 0, -0.707106769, 0, 0.707106769)
        UnionOperation2.Orientation = Vector3.new(0, 45, 0)
        UnionOperation2.Position = Vector3.new(22.0826416, 1.125, -81.2719879)
        UnionOperation2.Rotation = Vector3.new(0, 45, 0)
        UnionOperation2.Color = Color3.new(0.639216, 0.635294, 0.647059)
        UnionOperation2.Size = Vector3.new(3.04182434, 0.250000119, 3.04181671)
        UnionOperation2.BrickColor = BrickColor.new("Medium stone grey")
        UnionOperation2.brickColor = BrickColor.new("Medium stone grey")
        for i,v in pairs(mas:GetChildren()) do
            v.Parent = workspace
            pcall(function() v:MakeJoints() end)

        end
        ChangeHistoryService:SetWaypoint("Created Conveyor")
        mas:Destroy()
        for i,v in pairs(cors) do
            spawn(function()
                pcall(v)
            end)
        end

    end
end

function createSpawn()
    --Converted with ttyyuu12345's model to script plugin v4
    local function sandbox(var,func)
        local env = getfenv(func)
        local newenv = setmetatable({},{
            __index = function(self,k)
                if k=="script" then
                    return var
                else
                    return env[k]
                end
            end,
        })
        setfenv(func,newenv)
        return func
    end
    cors = {}
    mas = Instance.new("Model",game:GetService("Lighting"))
    Model0 = Instance.new("Model")
    WedgePart1 = Instance.new("WedgePart")
    SpawnLocation2 = Instance.new("SpawnLocation")
    Decal3 = Instance.new("Decal")
    WedgePart4 = Instance.new("WedgePart")
    WedgePart5 = Instance.new("WedgePart")
    WedgePart6 = Instance.new("WedgePart")
    Model0.Name = "SpawnPoint"
    Model0.Parent = mas
    WedgePart1.Parent = Model0
    WedgePart1.CFrame = CFrame.new(38.5, 0.5, -91.25, 0, 0, -1, 0, 1, 0, 1, 0, 0)
    WedgePart1.Orientation = Vector3.new(0, -90, 0)
    WedgePart1.Position = Vector3.new(38.5, 0.5, -91.25)
    WedgePart1.Rotation = Vector3.new(0, -90, 0)
    WedgePart1.Size = Vector3.new(4, 1, 1)
    WedgePart1.Anchored = true
    WedgePart1.BottomSurface = Enum.SurfaceType.Smooth
    WedgePart1.CanCollide = false
    SpawnLocation2.Parent = Model0
    SpawnLocation2.CFrame = CFrame.new(36, 0.5, -91.25, 1, 0, 0, 0, 1, 0, 0, 0, 1)
    SpawnLocation2.Position = Vector3.new(36, 0.5, -91.25)
    SpawnLocation2.Size = Vector3.new(4, 1, 4)
    SpawnLocation2.Anchored = true
    SpawnLocation2.BottomSurface = Enum.SurfaceType.Smooth
    SpawnLocation2.CanCollide = false
    SpawnLocation2.TopSurface = Enum.SurfaceType.Smooth
    Decal3.Parent = SpawnLocation2
    Decal3.Texture = "rbxasset://textures/SpawnLocation.png"
    Decal3.Face = Enum.NormalId.Top
    WedgePart4.Parent = Model0
    WedgePart4.CFrame = CFrame.new(36, 0.5, -88.75, -1, 0, 0, 0, 1, 0, 0, 0, -1)
    WedgePart4.Orientation = Vector3.new(0, 180, 0)
    WedgePart4.Position = Vector3.new(36, 0.5, -88.75)
    WedgePart4.Rotation = Vector3.new(-180, 0, -180)
    WedgePart4.Size = Vector3.new(4, 1, 1)
    WedgePart4.Anchored = true
    WedgePart4.BottomSurface = Enum.SurfaceType.Smooth
    WedgePart4.CanCollide = false
    WedgePart5.Parent = Model0
    WedgePart5.CFrame = CFrame.new(33.5, 0.5, -91.25, 0, 0, 1, 0, 1, -0, -1, 0, 0)
    WedgePart5.Orientation = Vector3.new(0, 90, 0)
    WedgePart5.Position = Vector3.new(33.5, 0.5, -91.25)
    WedgePart5.Rotation = Vector3.new(0, 90, 0)
    WedgePart5.Size = Vector3.new(4, 1, 1)
    WedgePart5.Anchored = true
    WedgePart5.BottomSurface = Enum.SurfaceType.Smooth
    WedgePart5.CanCollide = false
    WedgePart6.Parent = Model0
    WedgePart6.CFrame = CFrame.new(36, 0.5, -93.75, 1, 0, 0, 0, 1, 0, 0, 0, 1)
    WedgePart6.Position = Vector3.new(36, 0.5, -93.75)
    WedgePart6.Size = Vector3.new(4, 1, 1)
    WedgePart6.Anchored = true
    WedgePart6.BottomSurface = Enum.SurfaceType.Smooth
    WedgePart6.CanCollide = false
    for i,v in pairs(mas:GetChildren()) do
        v.Parent = workspace
        pcall(function() v:MakeJoints() end)
    end
    ChangeHistoryService:SetWaypoint("New SpawnPoint")
    mas:Destroy()
    for i,v in pairs(cors) do
        spawn(function()
            pcall(v)
        end)
    end
    return nil
end
0
By the way I did try using ModuleScripts but they didn't even load ANullMan 0 — 3y
0
You're passing the Callbacks before defining the functions; you're also calling them. Ziffixture 6913 — 3y

Answer this question