#How do i access a variable in a function?
23 messages · Page 1 of 1 (latest)
you can use the KeyframeReached event of the AnimationTrack object
u can use this event to trigger custom behavior at specific points in the animation
as for accessing variables in a function, you can do this by defining the variable outside of the function
for example:
local myVariable = 0
local function myFunction()
myVariable = myVariable + 1
end
u can now access it from other scripts aswell
here's an example for this:
local animationTrack = animation_track
local targetKeyframeName = "theKeyFrame"
animationTrack.KeyframeReached:Connect(function(keyframeName)
if keyframeName == targetKeyframeName then
-- add your custom behavior here
end
end)
what
The animation object
Like there u need the path to it
uh
its like
the animation
u have
u need write it there
** You are now Level 4! **
what's the error? show the script
have you tried saving animations in ReplicatedStorage instead?
it's easier. you can just put it there with all the properties and just call it in the script
also, maybe KeyFrameReached is typed wrong or something. I don't know really, I never used that event
usually, I just put a wait to the time I want instead of waiting for a note in the animation