I'm making a custom inventory GUI.
For whatever reason whenever a gun gets equipped for the first time it's really glitchy, but then when it gets equipped again it's fine. I waited for all the assets to load in the gun first too & use :WaitForChild in both the script below and the gun's scripts. There are no errors in output.
The gun also doesn't unequip.
Script:
equipped = false
game.ReplicatedStorage.Events.EquipUnequipEvent.OnServerEvent:Connect(function(plr, equippedVal, humanoid, scriptActivateImg, equippedImage, unequippedImage)
if equippedVal.Value ~= "" then
if equipped == false then
local Tools = game.ReplicatedStorage:WaitForChild("Tools")
humanoid:EquipTool(Tools[equippedVal.Value]) --glitching here?
print("equipped")
equipped = true
elseif equipped == true then
humanoid:UnequipTools() --glitching here?
print("unequipped")
equipped = false
end
end
end)
Thanks!
