EquipTool working in studio but not in-game

I’m using a custom hotbar/inventory system for items, and i’ve made it where you can equip tools, which works in studio:

However, when I go into the actual game and try using the tool, nothing happens.

Here’s the code that handles the equipping and unequipping part of the tool.

While it may be pretty inefficient, still should sync across both studio and game, but it doesn’t.

1 Like

Is there any errors within the Roblox client dev-console?

2 Likes

Nope, both studio and in-game are clean, and the equipTool function does actually run, but nothing happens.

1 Like

That’s weird. Can you try making the script code copyable so I can try?

1 Like

Like pasting it here? Sure,

repS:WaitForChild(“Remotes”):WaitForChild(“ItemEquip”).OnServerEvent:Connect(function(player, item, status)
local plrInfo = player:WaitForChild(“PlayerInfo”)
local char = player.Character
local humanoid = char:WaitForChild(“Humanoid”)

if status == true then
	if not serverS:WaitForChild("Draggable"):FindFirstChild(item) then warn("add the item into server storage") return end
	if not plrInfo:WaitForChild("PlayerInventory"):WaitForChild("Backpack"):FindFirstChild(item) and not plrInfo:WaitForChild("PlayerInventory"):WaitForChild("Hotbar"):FindFirstChild(item) then return end
	
	local tool = serverS:WaitForChild("Draggable"):FindFirstChild(item):Clone()
	humanoid:EquipTool(tool)
	
	for i, v in tool:GetChildren() do
		if v:IsA("BasePart") and v:FindFirstAncestorOfClass(workspace.Name) then
			v:SetNetworkOwner(nil)
			v.CanCollide = false
		end
	end
	
	for i, v in humanoid.Parent:GetChildren() do
		if v:IsA("BasePart") then
			v:SetNetworkOwner(player)
		end
	end
else
	humanoid:UnequipTools()
end

end)

formatting seems a bit broken, so apologies for that but im not sure how to fix it

1 Like

I have no idea if some kind of instance called “PlayerInfo” exists in the player.

1 Like

The PlayerInfo is unimportant and just acts as an anti cheat, removing it changes essentially nothing.

Restarted studio and now it doesn’t work here either, so at least theres that, thanks for trying either way

1 Like

The dumbest reason for it not working, but we all make this mistake, is did you publish the update to ROBLOX!

1 Like

yep, numerous times and added indicators to make sure 100% that it updated.

2 Likes

yet the problem was simply restarting studio and it synced up ;-;

1 Like

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