-
What do you want to achieve?
I want my localscript to “hold” an animation when a tool’s Activated event fires, likened to that of a left click to hold an animation. -
What is the issue?
Since I am relatively foreign to animation, I am not sure how I would implement this. I have established a KeyFrame reached event but to no avail. Please bear with me as I am also in my 4th week of scripting -
What solutions have you tried so far?
I have looked for several alternatives on the DevForum, but no joy. I am hoping that here in this article, someone willing could articulate my issues and address them.
Code:
local player = game:GetService("Players").LocalPlayer
local character = ((player.Character and player.Character.Parent) and player.Character) or player.CharacterAdded:Wait()
local Animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
local Soda_Animation = script.Parent:FindFirstChild("Animation")
local Soda_Track = Animator:LoadAnimation(Soda_Animation)
local drinking = true
script.Parent.Activated:Connect(function()
if drinking then
drinking = false
Soda_Track:Play()
Soda_Track.KeyframeReached:Connect(function(keyframeName) --KeyframeReached event doesn't fire
print("hello1")
if keyframeName == "KeyFrame2" then
print("hello")
Soda_Track:AdjustSpeed(0)
end
end)
end
end)
script.Parent.Deactivated:Connect(function()
Soda_Track:Stop()
drinking = true
end)```
