So I have been making a hotbar,
When spawning the tools into the custom gui I have to name them the index of the tool so the number enabling works efficiently. but I ran into a dilema. for some reason roblox is indexing the tools as 3 onwards instead of starting at 1. so when going ingame to enable tools the tools start at 5,6,7 instead of 1,2,3.
Please can someone help!
for __, tool in pairs(Player.Backpack:GetChildren()) do
if tool:IsA("Tool") then
local Ref = script.Template:Clone()
Ref.Name = __
Ref.Text = tool.Name
Ref.Parent = script.Parent.Frame
Ref.Visible = true
tool.Equipped:Connect(function()
local Found = Ref
local tweenOn = TweenService:Create(Ref.Round, TweenInfo.new(0.2), {ImageColor3 = Color3.fromRGB(85, 170, 255)})
local tweenOff = TweenService:Create(Ref.Round, TweenInfo.new(0.2), {ImageColor3 = Color3.fromRGB(30, 30, 30)})
tweenOn:Play()
end)
tool.Unequipped:Connect(function()
local Found = Ref
local tweenOn = TweenService:Create(Ref.Round, TweenInfo.new(0.2), {ImageColor3 = Color3.fromRGB(85, 170, 255)})
local tweenOff = TweenService:Create(Ref.Round, TweenInfo.new(0.2), {ImageColor3 = Color3.fromRGB(30, 30, 30)})
tweenOff:Play()
end)
Ref.MouseButton1Down:Connect(function()
if Player.Character:FindFirstChild(Ref.Text) then
Player.Character.Humanoid:UnequipTools()
else
Player.Character.Humanoid:EquipTool(Player.Backpack:FindFirstChild(Ref.Text))
end
end)
end
end