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)
