I’m beyond confused right now.
I am trying to equip an item with my own custom quick inventory, so whenever the player clicks on an item in the inventory the item is supposed to be equipped on the player. There aren’t any problems in studio, neither are there any problems when I’m in-game by myself. The problem is that when I’m in-game with other players the tool is only equipped for a random amount of seconds before it unequips or deletes or something. I have seen other posts talk about this and mention that its due to the code not being filtering enabled. However, the tool gets loaded in and parents to the character from the server. Is it due to the item coming from the player’s backpack? How do I actually equip the item then?
StarterPlayerScripts
function gadget_select:DeselectSlot(slot)
print("deselecting slot")
for i,v in pairs(slots) do
v.BorderColor3 = default_color
end
if not slot then
--hum:UnequipTools()
attach_tool:FireServer(nil)
else
-- idk yet
end
current_equipped_slot = nil
infoTxt.Text = ""
infoUI.Visible = false
end
function gadget_select:SelectSlot(slot)
local key = slot
local id
print("selecting slot")
if typeof(slot) == "string" then
key = slots[slot]
id = currentIDs[slot].Value
else
id = currentIDs[key.Name].Value
end
if id and id ~= 0 then
self:DeselectSlot()
local item = backpack[id] or char[id]
local item_info = item.item_info
for i,v in pairs(slots)do
if v ~= key then
v.BorderColor3 = default_color
else
current_equipped_slot = v.Name
v.BorderColor3 = selected_color
end
end
infoTxt.Text = item_info.gadget_directions.Value
infoUI.Visible = true
--hum:EquipTool(item)
attach_tool_event:FireServer(item)
end
end
ServerScriptService
attachToolEvent.OnServerEvent:Connect(function(plr, item)
local char = plr.Character
local hum = char.Humanoid
if not item then
print("removing item")
hum:UnequipTools()
else
item.Parent = char
print("adding item")
hum:EquipTool(item)
end
end)