game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
local player = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")

if not player.Character:FindFirstChildOfClass("Tool") then 
    player.Character.Humanoid:EquipTool("MK18") end

for index, tool in pairs (player.Backpack:GetChildren()) do
    if tool:IsA("Tool") and tool.Name == "MK18" then
        tool.Unequipped:Connect(function()
            tool.Parent = player.Character
        end)
    end
end

This code doesn't auto-equip my tool, Its in StarterPlayerCharacter and it gives me an error that says "Unable to cast value to Object"

1 comment

0

you are trying to equip string "MK18"