Equipping a tool makes it look laggy/weird

Hey,
I am struggling to equip a tool to a player in a localscript.

local tool = LocalPlayer.Character:FindFirstChild((slot.ItemName.Value:gsub(" ", "")))

                    if tool then
                        LocalPlayer.Character.Humanoid:UnequipTools()
                    else
                        local backpackTool = LocalPlayer.Backpack:FindFirstChild((slot.ItemName.Value:gsub(" ", "")))

                        if backpackTool then
                            LocalPlayer.Character.Humanoid:EquipTool(backpackTool)
                        end
                    end

It seems to be lagging the equipping of the tool or it just waits for the arm to complete the movement which makes it very unnatural and weird


Any ideas?

Have you tried publishing and testing in the actual game because sometimes studio can be glitchy when testing using “Play”

I didn’t, it maybe wise to do so. Can I publish a game only to myself or delete it after?

You could make the game private so only you can play it then publish it

Alright, thanks. Is it good to equip the tools on the client or is it better to send a remote event to the server for it to equip it?

How is this script called?
Is it in a function?
Is it part of a while true do loop?

If there is lag caused by the script itself then setting the variable by looping through a table every single time could be part of your issue.

Are you setting the local tool = every time you call the function when calling it once at the beginning of the script is all that’s required?

Instead of :UnequipTools(), try finding the tool any manually parenting to their backpack.

It is a Localscript in a ScreenGui which equips a tool on a button press so it is in a InputBegan function.

Why is the tool stored in a table? Why not just load it into the player Backpack and search for it there?