So I have this code that only runs if the sword is equipped but it doesnt seem to sense if the sword is in hand. Help?
local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local Char = plr.Character
local BlockAnim = script:WaitForChild('BlockAnim')
local Keydown = false
local Hum = Char.Humanoid
local Anim = Hum:LoadAnimation(BlockAnim)
local tool = game.StarterPack.ClassicSword
local ToolEquip = false
tool.Equipped:Connect(function()
ToolEquip = true
end)
tool.Unequipped:Connect(function()
ToolEquip = false
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
Keydown = true
end
while Keydown == true and ToolEquip == true do
wait(.1)
Anim:Play()
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
Keydown = false
end
while Keydown == false do
wait(.1)
Anim:Stop()
end
end)
this is was all in a local script and is inside of starter character scripts

2 comments
Why not make it inside the tool
its because then i get an error saying Players.Tan0ak.Backpack.ClassicSword.BlockingScript:6: attempt to index nil with 'Humanoid'