I’m working on making my own custom toolbar but whenever I pick up a tool it doesn’t work as expected.
Fired when child is added into character
local function toolPickup(tool)
local findTool = table.find(currentTools,tool)
if tool:IsA("Tool") and not findTool then
local toolButton = addButton(tool) --//sets the index of the tool
toggleToolButton(tool,toolButton)
equippedButtonName = tostring(table.find(currentTools,tool))
end
end
function that is the root cause of the issue:
local function toggleToolButton(tool,toolButton)
untoggleLastTool(toolButton)
if tool.Parent == backpack then
task.wait(.1)
tool.Parent = character
toolButton.ImageColor3 = BUTTON_COLORS.Highlighted
elseif tool.Parent == character then
tool.Parent = backpack
toolButton.ImageColor3 = BUTTON_COLORS.Default
end
local tertiary = tool.Parent == character and toolButton.Name
equippedButtonName = tertiary
end
In the function above, I put a task.wait because I realized that there was a short moment where roblox was calculating what to do when I picked up the tool.
I believe it put the tool in my backpack and then instantly in my character for a short second.
If I don’t use a wait, then the tool will just drop out of my hands like so:
If I do, it’ll just be delayed but work as planned. Is there any way to silence these backend calculations?