Hello,
I am having an issue in my roblox game where the tool I have is not going into my backpack. I have it in starterpack, and I have a custom hotbar system. When the game loads, I can see that it is in my backpack, but it is not in my custom hotbar. Here is a video that may help you understand my issue:
https://vimeo.com/546690125
Also, here is my Hotbar Script:
--// Variables local plr = game.Players.LocalPlayer local UI = script.Parent local MainFrame = UI.MainFrame local StrNum = {["One"] = "1", ["Two"] = "2", ["Three"] = "3", ["Four"] = "4", ["Five"] = "5", ["Six"] = "6", ["Seven"] = "7", ["Eight"] = "8", ["Nine"] = "9"} local SlotData = { CurrentSlot = nil, Slots = { ["Slot1"] = {Equipped = false, CurrentTool = false, Index = 1}, ["Slot2"] = {Equipped = false, CurrentTool = false, Index = 2}, ["Slot3"] = {Equipped = false, CurrentTool = false, Index = 3}, ["Slot4"] = {Equipped = false, CurrentTool = false, Index = 4}, ["Slot5"] = {Equipped = false, CurrentTool = false, Index = 5}, ["Slot6"] = {Equipped = false, CurrentTool = false, Index = 6}, ["Slot7"] = {Equipped = false, CurrentTool = false, Index = 7}, ["Slot8"] = {Equipped = false, CurrentTool = false, Index = 8}, ["Slot9"] = {Equipped = false, CurrentTool = false, Index = 9} } } --// Disable Default Hotbar game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) --// Functions function getNextEmptySlot() local possibleSlots = {} for i, v in pairs(SlotData.Slots) do if v.CurrentTool == false then table.insert(possibleSlots, v) end end local function lowestNumber() local low = 10 --// Add num for i, v in pairs(possibleSlots) do if v.Index < low then low = v.Index end end return low end local num = tostring(lowestNumber()) if num ~= nil then return SlotData.Slots["Slot"..num] else return nil end end function updateSlots() for i, v in pairs(SlotData.Slots) do local uiSlot = MainFrame:FindFirstChild("Slot"..tostring(v.Index)) uiSlot.SlotName.TextColor3 = Color3.fromRGB(255, 255, 255) uiSlot.bg.ImageColor3 = Color3.fromRGB(46, 46, 46) uiSlot.ToolName.TextColor3 = Color3.fromRGB(255, 255, 255) if v.CurrentTool == false then uiSlot.ToolName.Text = "" elseif v.CurrentTool ~= false then uiSlot.ToolName.Text = v.CurrentTool.Name if v.CurrentTool.Parent ~= plr.Character and v.CurrentTool.Parent ~= plr.Backpack then uiSlot.ToolName.Text= "" v.Equipped = false v.CurrentTool = false end end if v.Equipped == true then uiSlot.SlotName.TextColor3 = Color3.fromRGB(0, 170, 255) uiSlot.bg.ImageColor3 = Color3.fromRGB(255, 255, 255) uiSlot.ToolName.TextColor3 = Color3.fromRGB(46, 46, 46) end end end function equipSlot(slot_num) local done = false local Slot = SlotData.Slots["Slot"..slot_num] local uiSlot = MainFrame:FindFirstChild("Slot"..slot_num) if done == false then done = true if Slot.Equipped == false then for i, v in pairs(MainFrame:GetChildren()) do if v.ClassName == "ImageButton" then v.SlotName.TextColor3 = Color3.fromRGB(255, 255, 255) v.bg.ImageColor3 = Color3.fromRGB(46, 46, 46) v.ToolName.TextColor3 = Color3.fromRGB(255, 255, 255) end end for i, v in pairs(plr.Character:GetChildren()) do if v:IsA("Tool") and v~= Slot.CurrentTool then wait() v.Parent = plr.Backpack end end for i, v in pairs(SlotData.Slots) do v.Equipped = false end SlotData.Current = Slot Slot.Equipped = true if Slot.CurrentTool ~= false then Slot.CurrentTool.Parent = plr.Character uiSlot.ToolName.Text = Slot.CurrentTool.Name end --uiSlot.SlotName.TextColor3 = Color3.fromRGB(0, 170, 255) // Test --uiSlot.bg.ImageColor3 = Color3.fromRGB(255, 255, 255) --uiSlot.ToolName.TextColor3 = Color3.fromRGB(46, 46, 46) updateSlots() wait(.2) done = false elseif Slot.Equipped == true then for i, v in pairs(MainFrame:GetChildren()) do if v.ClassName == "ImageButton" then v.SlotName.TextColor3 = Color3.fromRGB(255, 255, 255) v.bg.ImageColor3 = Color3.fromRGB(46, 46, 46) v.ToolName.TextColor3 = Color3.fromRGB(255, 255, 255) end end for i, v in pairs(plr.Character:GetChildren()) do if v:IsA("Tool") then wait() v.Parent = plr.Backpack end end for i, v in pairs(SlotData.Slots) do v.Equipped = false end SlotData.CurrentSlot = nil wait(.2) done = nil end end end for i, v in pairs(MainFrame:GetChildren()) do if v.ClassName == "ImageButton" then v.MouseButton1Click:Connect(function() equipSlot(v.Name:sub(5)) updateSlots() end) end end game:GetService("UserInputService").InputBegan:Connect(function(key) for i, v in pairs(StrNum) do if key.KeyCode == Enum.KeyCode[i] then if MainFrame:FindFirstChild("Slot"..v) then equipSlot(v) updateSlots() else print("Slot"..v, "Does not exist") end end end if key.KeyCode == Enum.KeyCode.Backspace then if SlotData.CurrentSlot ~= nil then updateSlots() end end end) plr.Backpack.ChildAdded:Connect(function(newChild) for a, b in pairs(SlotData.Slots) do if b.CurrentTool == newChild then return end end local Slot = getNextEmptySlot() if Slot ~= nil then Slot.CurrentTool = newChild equipSlot(tostring(Slot.Index)) updateSlots() end end) plr.Character.ChildAdded:Connect(function(newChild) if newChild:IsA("Tool") then for a, b in pairs(SlotData.Slots) do if b.CurrentTool == newChild then return end end local Slot = getNextEmptySlot() if Slot ~= nil then Slot.CurrentTool = newChild equipSlot(tostring(Slot.Index)) updateSlots() else newChild.Parent = workspace end end end)
Please help if you can.
Thanks!