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

Items not equipping in custom inventory system?

Asked by 6 years ago

Im trying to make an inventory system, a drag inventory system, yet i found something strange. It works perfectly in Studio, yet when i hop onto Roblox, the items dont' equip. Why? I don't know.

This is the "Flawed 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
            Char:FindFirstChildOfClass('Tool'):Destroy()
        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)
            if SlotEquip.Tool.Value ~= nil then Humanoid:EquipTool(SlotEquip.Tool.Value:Clone()) end
        elseif SlotEquip.Equipped.Value == true and SlotEquip.Tool.Value ~= nil then
            Dequip(Char)
        end
    end
end)



1 answer

Log in to vote
0
Answered by 6 years ago

Dear Qu4n7um7, This isn't really an answer but if you'd like I could help you with this in roblox because i have a setup very similar to this and you could have it if you'd like, Just message my user (in order to do so please click three dots and follow then refresh page) and i'll get back to you with an answer.

Ad

Answer this question