hey dudes im trying to make a script for my friend and i need a bit of help since GetMarkerReachedSignal does simply not trigger
local mdl = script.Parent
local humanoid = mdl:WaitForChild("Humanoid")
local anim = humanoid:LoadAnimation(mdl:FindFirstChild("stomp"))
while true do
wait(5)
anim:Play()
end
anim:GetMarkerReachedSignal("stomp"):Connect(function()
print("stomp time")
end)
(doesnt print anything)
video of the event in the animation in case its needed
local mdl = script.Parent
local humanoid = mdl:WaitForChild("Humanoid")
local anim = humanoid:LoadAnimation(mdl:FindFirstChild("stomp"))
anim:GetMarkerReachedSignal("stomp"):Connect(function()
print("stomp time")
end)
while true do
wait(5)
anim:Play()
end
The message didnt get printed to the output because of the while true do loop.
If you didnt know already, any type of loop will change the control flow of the script’s execution into the loop’s body, which basically means that the rest of the script will not get executed until the loop breaks.
Since the marker get reached signal event was after the loop, the script has never reached it/never executed it, hence why it isn’t working.
I hope you learned something new today!
I’ll just add on to what this guy wrote for your general knowledge @Dimayuplay, if you need a loop but don’t want to stop code execution use task.spawn or task.delay if you wish to delay it
task.spawn(function()
while true do
wait(5)
anim:Play()
end
end)