Basically I am trying to make it so when RightClick is being held then an animation plays.
Its a server script and its in a tool.
The only thing that happens is it prints “equip” then stops, no errors.
local LightSaber = script.Parent
local player = LightSaber.Parent.Parent
local Character = player.Character
local humanoid = Character.Humanoid
local hold -- if player is holding right click
local equipped
local UserInputService = game:GetService("UserInputService")
local Block1 = humanoid:LoadAnimation(script:WaitForChild('Block1'))
local Block2 = humanoid:LoadAnimation(script:WaitForChild('Block2'))
local Block3 = humanoid:LoadAnimation(script:WaitForChild('Block3'))
Block1.Priority = Enum.AnimationPriority.Action
Block2.Priority = Enum.AnimationPriority.Action4
Block3.Priority = Enum.AnimationPriority.Action
equipped = false
script.Parent.Equipped:Connect(function()
print("equip") -- Only thing printed
equipped = true
end)
script.Parent.Unequipped:Connect(function()
equipped = false
end)
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if (gameProcessedEvent) then
return
end
if (input.UserInputType == Enum.UserInputType.MouseButton2) then
if equipped == true then
print("hold is true and equip") -- Never prints
hold = true
end
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessedEvent)
if (gameProcessedEvent) then
return
end
if (input.UserInputType == Enum.UserInputType.MouseButton2) then
if equipped == true then
print("hold is false and equip") -- Never prints
hold = false
end
end
end)
while wait() do
if hold and equipped == true then
Block1:Play()
wait(0.15)
if hold and equipped == true then
Block2:Play()
wait(0.15)
if hold and equipped == true then
Block3:Play()
wait(0.15)
return
end
end
else
Block1:Stop()
Block2:Stop()
Block3:Stop()
end
end
I really don’t know why this is happening, pretty sure I am using UserInputService correctly but maybe not?