I’m making a script for animation of some model, and at certains points of the animation I need several events to happen.
I wanted to use GetMarkerReachingSignal for this, I named the keyframes and made this script, but for some reason the script can’t detect when a keyframe is played, and in result nothing happens, including no errors in output.
My issue is that the script seems not to be able to notice when a keyframe is hit in the animation, and my goal is to manage script to detect whenever a named keyframe is hit.
I followed roblox documentation article to script this (link below).
Script (the script is not final and prints are made so I can notice did something work or not):
local tv = script.Parent
local frame = tv.Frame
local screen = tv.Screen
local pe1 = frame.ParticleEmitter1
local pe2 = screen.ParticleEmitter2
local pe3and1 = frame.Attachment1.ParticleEmitter3
local pe3and2 = frame.Attachment2.ParticleEmitter3
local pe3and3 = frame.Attachment3.ParticleEmitter3
local pe3and4 = frame.Attachment4.ParticleEmitter3
local rs = game:GetService("ReplicatedStorage")
local tvf1event = rs.MetroMap.Part1.Area2.TVFall1Event
local sounds = frame.Sounds
local function fireevent1()
local humanoid = script.Parent.Humanoid
local findanim1 = script.Parent.AnimSaves.TVFall1Anim
local anim1 = humanoid:LoadAnimation(findanim1)
local function pe3enable()
pe3and1.Enabled = true
pe3and2.Enabled = true
pe3and3.Enabled = true
pe3and4.Enabled = true
end
local function pe3disable()
pe3and1.Enabled = false
pe3and2.Enabled = false
pe3and3.Enabled = false
pe3and4.Enabled = false
end
local function flick1()
local mr1 = math.random(1,3)
if mr1 == 1 then
sounds.Flicks1:Play()
pe2.Enabled = true
wait(0.15)
pe2.Enabled = false
wait(0.15)
end
if mr1 == 2 then
sounds.Flicks1:Play()
pe2.Enabled = true
wait(0.15)
pe2.Enabled = false
wait(0.25)
end
if mr1 == 3 then
sounds.Flicks1:Play()
pe2.Enabled = true
wait(0.25)
pe2.Enabled = false
wait(0.5)
end
sounds.Flicks1:Stop()
end
local function act1()
print("6")
anim1:GetMarkerReachedSignal("Act1"):Connect(function()
pe3enable()
wait(0.15)
pe3disable()
print("1")
end)
anim1:GetMarkerReachedSignal("Act2"):Connect(function()
pe3enable()
wait(0.15)
pe3disable()
print("2")
end)
anim1:GetMarkerReachedSignal("Act3"):Connect(function()
pe3enable()
print("3")
end)
anim1:GetMarkerReachedSignal("Act3End"):Connect(function()
pe3disable()
print("4")
end)
anim1:GetMarkerReachedSignal("End"):Connect(function()
pe1.Enabled = true
flick1()
wait(0.25)
pe1.Enabled = false
print("5")
end)
end
anim1:Play()
act1()
anim1:GetMarkerReachedSignal("End"):Connect(function()
print("7")
end)
end
tvf1event.Event:Connect(function()
fireevent1()
end)
Link to the article I followed: AnimationTrack | Roblox Creator Documentation
(the script was little outdated had to edit it)