Hi, I had some troubles with my scripts, I was trying to make a script where if an animation hits a certain keyframe it runs a function, but for some reason when I was testing it, the functions were run at the 1st frame of the animation but not the event frame. For example: This is the function I try to run when the animation hits the determined keyframe:
local function PauseResume(Track) if Track.Speed == 1 then Track:AdjustSpeed(0) else Track:AdjustSpeed(1) end end
With this it runs properly:
Track:GetMarkerReachedSignal("EventFrame"):Connect(function() PauseResume(Track) end)
But when trying to run it in a function, this fires at the 1st keyframe (not the keyframe I wanted it to run):
local function KeyframeEvent(Track,EventName,Funct) Track:GetMarkerReachedSignal(EventName):Connect(function() Funct() end) end
KeyframeEvent(Track,"EventFrame",PauseResume(Track))
Why does this happen?