#how do i make the argument optional

1 messages · Page 1 of 1 (latest)

tight heath
#
    {{'rtp'}, {'Refreshes the player. if ":rtp true", gets rid of your tools.'}, 0, {"boolean"},
            local character = pl.Character
            if not character then return end
            local keepTools = args[1] == not true
            local stamina = pl:GetAttribute("Stamina") or 100
            local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
            if not humanoidRootPart then return end
            local savedCFrame = humanoidRootPart.CFrame
            local savedTools = {}
            if keepTools then
                for _, tool in ipairs(pl.Backpack:GetChildren()) do
                    if tool:IsA("Tool") then
                        table.insert(savedTools, tool:Clone())
                    end
                end
                for _, tool in ipairs(character:GetChildren()) do
                    if tool:IsA("Tool") then
                        table.insert(savedTools, tool:Clone())
                    end
                end
            end
            pl:LoadCharacter()
            character = pl.Character or pl.CharacterAdded:Wait()
            humanoidRootPart = character:WaitForChild("HumanoidRootPart")
            humanoidRootPart.CFrame = savedCFrame
            pl:SetAttribute("Stamina", stamina)
            if keepTools then
                for _, tool in ipairs(savedTools) do
                    tool.Parent = pl.Backpack
                end
            end
        end
    },
}```

this is the command, how do i make the arg optional
if they run :rtp i want it to be the same as :rtp false (and keep the tools)
silk cairn
#

@green dome issue is this line

#
local keepTools = args[1] == not true```
#

not true is basically false

#

so youre just doing args[1] == false

#
local removeTools = args[1] == true
local keepTools = not removeTools```