Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is EquipTool() not giving the character the tool?

Hi! I am making a hotbar system. I already have an inventory system which you can put the tools in the hotbar. When you equip the tools in the inventory it works, but when you press on the slot in the hotbar it doesnt work even though they use the same script? Please help

Local Script:

local button = script.Parent
local plr = game.Players.LocalPlayer

local selected = script.Parent:WaitForChild("Selected")
local equipped = script.Parent.Parent.Parent.Frame.Handler.Equipped
local location = script.Parent.Parent.Parent.Frame.Handler.Location

button.MouseButton1Click:Connect(function()
	if plr and plr.Character then
		local character = plr.Character
		if equipped.Value == nil or equipped.Value ~= selected.Value then 
			character.Humanoid:UnequipTools() 
			print("Tool")
			if location.Value == plr.Backpack then
				print("HOT BAR1:".. button:FindFirstChild("Selected").Value.Name)

				character:WaitForChild("Humanoid"):EquipTool(selected.Value)
				equipped.Value = selected.Value
				print("Equipping Tool")
			end
		else

			character.Humanoid:UnequipTools()
			equipped.Value = nil
			print("Unequipping tool")
		end
		character.Humanoid:UnequipTools()
	end
end)

4 comments

0

I edited it because it wasn't formatted correctly

0

all the prints are firing btw it's just the equip tool not working correctly

0

what is selected ?

0

Where is the local script located? Try placing the local script in StarterPlayerScripts if you haven't already

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.