Hi (again), i was working on an equip items system, it works but only in studio…i have already read posts like this but they aren’t helping, this is my script:
Client:
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid") or character:WaitForChild("Humanoid")
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
local equipped = false
uis.InputBegan:Connect(function(input, chat)
if not chat then
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.One then
if equipped == false then
equipped = true
game.ReplicatedStorage.Remotes["Equip/Unequip"]:FireServer("Equip", humanoid)
else
equipped = false
game.ReplicatedStorage.Remotes["Equip/Unequip"]:FireServer("Unequip", humanoid)
end
end
end
end
end)
Server:
game.ReplicatedStorage.Remotes["Equip/Unequip"].OnServerEvent:Connect(function(player, action, humanoid)
if action == "Equip" then
humanoid:EquipTool(player.Backpack:FindFirstChild(player.EquippedItem.Value))
elseif action == "Unequip" then
humanoid:UnequipTools(player.Backpack:FindFirstChild(player.EquippedItem.Value))
end
end)
I’m doing this since i’m making a custom hotbar but as i said it works only in studio, if you are wondering if the player.EquippedItem.Value
isn’t nil then no it isn’t and the item exists in the player’s backpack, also i don’t get any error. I’m starting think it is a bug, what do you say about this?