Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Drag inventory system not equipping tools?

Asked by 6 years ago

So i've been at this for a long time: how do i fix my drag inventory system? It works fine in Studio, but doesnt' work in Roblox. Likely due to a Filtering Enabled bug, question is, what is the bug? I've tried everything to make this thing work from Cloning it on the server instead of the client, to sending the name of the tool of interest, and having the server look for the tool with that name and equipping it. None of which worked. When i do it in Studio, it works fine, when i do it in Roblox, it doesn't equip, it doesn't show errors, and i couldn't locate the source of the problem. There are 2 scripts that are supposed to make the tools equip: this is the Local Script:

--//Services
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")

--//Events
local UpdateAncestory = RS:WaitForChild('UpdateAncestory')

--//Objects
local Slots = { script.Parent:WaitForChild('One'), 
                script.Parent:WaitForChild('Two'),
                script.Parent:WaitForChild('Three'),
                script.Parent:WaitForChild('Four'),
                script.Parent:WaitForChild('Five'),
                script.Parent:WaitForChild('Six'),
                script.Parent:WaitForChild('Seven'),
                script.Parent:WaitForChild('Eight')}

--//PlayerObjects
--in code...

local Backpack = Players.LocalPlayer:WaitForChild('Backpack', math.huge)

--//Functions
function Dequip(Char)
    for i, v in ipairs(Slots) do
        v.Equipped.Value = false
        v.BackgroundColor3 = Color3.fromRGB(0,0,0)
        if Char:FindFirstChildOfClass('Tool') then
            UpdateAncestory:FireServer(Char:FindFirstChildOfClass("Tool").Name, Char, 'Unequip')
        end
    end
end

--//Code
UIS.InputBegan:connect(function(input)
    local Char = Players.LocalPlayer.Character
    local Humanoid = Char:WaitForChild('Humanoid')

    if script.Parent:FindFirstChild(input.KeyCode.Name) then
        local SlotEquip = script.Parent[input.KeyCode.Name]
        if SlotEquip.Equipped.Value == false and SlotEquip.Tool.Value ~= nil then
            Dequip(Char)
            SlotEquip.Equipped.Value = true
            SlotEquip.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
            print(SlotEquip.Tool.Value.Name..' client')
            if SlotEquip.Tool.Value ~= nil then UpdateAncestory:FireServer(SlotEquip.Tool.Value.Name, Humanoid, 'Equip') end
        elseif SlotEquip.Equipped.Value == true and SlotEquip.Tool.Value ~= nil then
            Dequip(Char)
        end
    end
end)


and here is the Server Script:

local UA = game:GetService("ReplicatedStorage"):WaitForChild('UpdateAncestory')


UA.OnServerEvent:connect(function(client, child, parent, typ)
    if typ ==  '' or typ == nil then
        child.Parent = parent
    elseif typ == 'Equip' then
        print(client.Backpack:FindFirstChild(child, true))

        local Item = client.Backpack:FindFirstChild(child, true):Clone()
        parent:EquipTool(Item)

    elseif typ == 'Unequip' then
        parent:FindFirstChild(child):Destroy()
    end
end)
1
what is "Dequip" User#19524 175 — 6y
0
in the server script, instead of finding the 'child' in the client's backpack, put the 'tool' in serverstorage, clone the tool, and make the player equip it hellmatic 1523 — 6y
0
toolclone.Parent = client.Character hellmatic 1523 — 6y
0
another method; in the server script, in OnServerEvent, :FireClient(toolName), in the client it gets the 'tool' and equips it hellmatic 1523 — 6y

Answer this question