As u can see the input began even works well - im trying to stop the current rightanimation on input ended but nothing seems to work.
i think its the code positioning - from adjusting the speed to playing but at this rate im lost.
someone please help me.
β //module
local module = {}
-- //Services
local UserInputService = game:GetService("UserInputService")
-- //Debounce
local Right = false
local Left = false
-- //
function module:input(player, character)
-- //
local Humanoid = character:WaitForChild("Humanoid")
local Animator = Humanoid:FindFirstChild("Animator")
-- //Animations
local RightAnimation = script:FindFirstChild("RightAnimation")
local LeftAnimation = script:FindFirstChild("LeftAnimation")
UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.ButtonR1 or input.KeyCode == Enum.KeyCode.ButtonR2 then
if not Right then
Right = true
local LoadAnimation = Animator:LoadAnimation(RightAnimation)
LoadAnimation.TimePosition = math.clamp(input.KeyCode.Value, 0, LoadAnimation.Length)
LoadAnimation:Play()
if LoadAnimation.IsPlaying then
wait(LoadAnimation.Length * 0) -- //whole animation = 1.1 seconds
LoadAnimation.TimePosition = 1
LoadAnimation:AdjustSpeed(0)
end
end
end
end)
UserInputService.InputEnded:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.ButtonR1 or input.KeyCode == Enum.KeyCode.ButtonR2 then
if Right then
local LoadAnimation = Animator:LoadAnimation(RightAnimation)
Right = false
LoadAnimation.TimePosition = math.clamp(input.KeyCode.Value, 0, LoadAnimation.Length)
LoadAnimation:Play()
LoadAnimation:AdjustSpeed(-1)
end
end
end)
end
return module
ill show you the video - Watch Reality - Roblox Studio 2025-02-15 11-21-47 | Streamable. Im sure its meant to reverse, the fingers bend on input shown but they dont reverse using the animation provide and the input ended and its kinda tricky understanding the animationtrack
I would try maybe having the animation loaded before the InputBegan? and then just pausing it and playing it in reverse depending on the situation maybe
I also think it may be a problem with the math.clamp but I am unsure : /
BRO SAVED ME - i had to just move the variable local LoadAnimation above the user input. THANK YOU.
local module = {}
-- //Services
local UserInputService = game:GetService("UserInputService")
-- //Debounce
local Right = false
local Left = false
-- //
function module:input(player, character)
-- //
local Humanoid = character:WaitForChild("Humanoid")
local Animator = Humanoid:FindFirstChild("Animator")
-- //Animations
local RightAnimation = script:FindFirstChild("RightAnimation")
local LeftAnimation = script:FindFirstChild("LeftAnimation")
local LoadAnimation = Animator:LoadAnimation(RightAnimation) -- //MOVED THIS UP HERE AND WORKS
UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.ButtonR1 or input.KeyCode == Enum.KeyCode.ButtonR2 then
if not Right then
Right = true
LoadAnimation.TimePosition = math.clamp(input.KeyCode.Value, 0, LoadAnimation.Length)
LoadAnimation:Play()
if LoadAnimation.IsPlaying then
wait(LoadAnimation.Length * 0) -- //whole animation = 1.1 seconds
LoadAnimation.TimePosition = 1
LoadAnimation:AdjustSpeed(0)
end
end
end
end)
UserInputService.InputEnded:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.ButtonR1 or input.KeyCode == Enum.KeyCode.ButtonR2 then
if Right then
Right = false
LoadAnimation.TimePosition = math.clamp(input.KeyCode.Value, 0, LoadAnimation.Length)
LoadAnimation:Play()
LoadAnimation:AdjustSpeed(-1)
end
end
end)
end
return module