My custom inventory didnt work

so, my purpose is > making custom inventory,
but i got a problem that confuse me, the problem is

  1. the item didnt show unless if i equip it in seccond try
  2. the item wont unequip

the properties is
image
local script in upper side

local playerhumanoid = player.Character:FindFirstChildOfClass("Humanoid")
local playercharacter = player.Character
local backpack = player.Backpack
local userinput = game:GetService("UserInputService")

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

print("here")
function untable (equiped)
	for _, v in pairs(equiped) do
		return backpack.equiped[v.Name]
	end
end
wait(2)
local equiped = untable(player.Backpack.equiped:GetChildren())

userinput.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.One then
		if playercharacter:FindFirstChildWhichIsA("Tool") then
			script.Script.unequip:FireServer(equiped)
		else
			script.Script.equip:FireServer(equiped)
		end
	end 
end)

while wait(0.1) do
	if equiped then
		script.Parent.Image = equiped.TextureId 
	else
		script.Parent.Image = "rbxassetid://8667892442"
	end
end

local script in down side

local position = script.Parent.Position
local player = game.Players.LocalPlayer
local hover = game.ReplicatedStorage.sound.hover
script.Parent.MouseEnter:Connect(function()
	script.Parent:TweenSize(size - UDim2.new(0.01, 0.01, 0.01, 0.01), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
	script.Parent:TweenPosition(position + UDim2.new(0.005, 0.005, 0.005, 0.005), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
	hover:Play()
end)
script.Parent.MouseLeave:Connect(function()
	wait(0.1)
	script.Parent:TweenSize(size, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
	script.Parent:TweenPosition(position, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1)
end)

the script

	local playerhumanoid = player.Character:FindFirstChildOfClass("Humanoid")
	playerhumanoid:EquipTool(tool)
	print("equipting "..tool.Name)
end)
script.unequip.OnServerEvent:Connect(function(player, tool)
	local playerhumanoid = player.Character:FindFirstChildOfClass("Humanoid")
	playerhumanoid:UnequipTools(tool)
	print("unequip "..tool.Name)
end)

sorry for bad engglish, i try best i can

NVM, my bad, i should use local script instead of script

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.