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

Need help finding formatting error with HD custom command?

Asked by 3 years ago

I'm making a command for HD Admin and I pasted a script I made a while ago and edited a few things and I can't find where my error is.

-- << RETRIEVE FRAMEWORK >>
local main = _G.HDAdminMain
local settings = main.settings

-- << COMMANDS >>
local module = {
    -----------------------------------
    {
        Name = "bubble",
        Aliases = {},
        Prefixes = {settings.Prefix},
        Rank = 1,
        RankLock = false,
        Loopable = false,
        Tags = {"fun"},
        Description = "Traps you inside a bubble that you can roll around in.",
        Contributors = {"OwOShiba"},
        --
        Args = {"Player"},
        Function = function(speaker, args)
            local PhysicsService = game:GetService("PhysicsService")

            if not args[1] then
                local player = speaker
            else
                local player = args[1]

                local Players = "Players"
                local Shield = "Shield"

                local function weld(x, y)
                    local weld = Instance.new("Weld", x)
                    weld.Part0 = x
                    weld.Part1 = y
                    weld.Parent = x
                end

                game.Players.PlayerAdded:Connect(
                    function(player)
                        player.CharacterAdded:Connect(
                            function(character)
                                for _, inst in pairs(character:GetChildren()) do
                                    if inst:IsA("BasePart") then
                                        PhysicsService:SetPartCollisionGroup(inst, Players)
                                    end
                                end
                            end
                        )

                        local Character = player.Character
                        local Root = Character:WaitForChild("HumanoidRootPart")
                        ------------------------------------------------------------
                        local part = Instance.new("Part")
                        part.Name = "Bubble"
                        part.Shape = Enum.PartType.Ball
                        part.Transparency = 1
                        part.Size = Vector3.new(15, 15, 15)
                        PhysicsService:SetPartCollisionGroup(part, Shield)
                        part.Anchored = false
                        part.CFrame = Root.CFrame
                        part.Massless = true

                        ---------------------------------------------

                        local descendants = player.Character:GetDescendants()
                        for _, inst in pairs(descendants) do
                            if inst:IsA("BasePart") and inst.CanCollide then
                                local noCollisionConstraint = Instance.new("NoCollisionConstraint")
                                noCollisionConstraint.Parent = part
                                noCollisionConstraint.Part0 = inst
                                noCollisionConstraint.Part1 = part
                            end
                        end
                        part.Parent = workspace
                        weld(Root, part)
                    end
                )
            end

            UnFunction = function(speaker, args)
                if not args[1] then
                    local player = speaker
                else
                    local player = args[1]

                    local descendants = player.Character:GetDescendants()
                    for _, inst in pairs(descendants) do
                        if inst:IsA("BasePart") and inst.CanCollide and inst.Name.match(inst.Name, "Bubble") then
                            inst.Destroy()
                        end
                    end
                end
            end
        end
        --
    }
}

return module

The error I get on UnFunction:

W003: Global 'UnFunction' is only used in the enclosing function defined at line 23; consider changing it to local

^Line 23 is

Function = function(speaker, args)
0
Think you need another end before the unfunction? cos the unfunction is inside the function rn i think. you need to end the function with end; (make sure to have a , or ; at the end of function and unfunction as it is still in a table) BulletproofVast 1033 — 3y
0
I would not use HD admin bc it allows hackers to hack your game. I generally do not trust these free model “admin scripts” as they are incredibly unreliable and have major security flaws. MAD_DENISDAILY2 137 — 3y
0
BulletproofVast answered ^ OwOShiba 78 — 3y

Answer this question