How can I make animations "hold"

I want to make a grenade throwing mechanic in a game. I want it to stay in a throwing position once the G key is pressed and stay there until it is released. How can I do this?

4 Likes

You could change the time position then set the animation speed to 0 which will freeze the animation

What do you mean the time and position of the animation?

It is a property of an animation track:

1 Like

Theres a lot of ways to do this I’d say one of the easiest would be creating 2 animations and copy the last frame of the animation and paste it on the second one. Then just loop it. Some people will make an animation longer and loop keyframes and theres some will try some other methods that they experiment with. For your sake assuming you aren’t that good at programming id say creating 2 animations will be the easiest for you.

This is probably a garbage way to do it but I did this:

Here is the game btw:

I have a local script that has an animation inside of it:
image

And i made an animation:

This is the script:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")


local Animtion = script.Animation
local AnimationTrack = Humanoid:LoadAnimation(Animtion)

local UIS = game:GetService("UserInputService")

local HeldDown = false


UIS.InputBegan:Connect(function(Input, GPE)
	if GPE == false then
		if Input.KeyCode == Enum.KeyCode.G then
			HeldDown = true
			AnimationTrack:Play()
			wait(AnimationTrack.Length / 2) -- for me the time when the players arm is up holding the grenade is in the middle of the animation
			AnimationTrack:AdjustSpeed(0)
		end
	end
end)

UIS.InputEnded:Connect(function(Input, GPE)
	if GPE == false then
		if Input.KeyCode == Enum.KeyCode.G then
			HeldDown = false
			AnimationTrack:AdjustSpeed(1)
			print("throw grenade")
		end
	end
end)

Im sure there is a better way to do this, but this is what I quickly came up with there are probably some bugs

3 Likes