AnimationEvents beeing called as much times as the animation were ever played. Help?
Asked by
5 years ago Edited 5 years ago
As far as i know:
- Im using Animation Event to cast a spell at a certain point of the animation,
- but everytime i call :Play() on the loaded track, it looks like it creates another extra parallel track,
- when i call :Stop() the track is actually still there in the background and stopped.
- Calling :Play() again creates a new one and restarts ALL of them.
- The event (for firing a spell) is called as much times as there are animations ever played in the "background" when the point of MarkedSignal of the one showing animation is reached.
In the end: - When i start an animation, the number of progectiles it casts is somehow multiplied by the times i've casten before, but im not 100% this what i describled is causing it.
How do I fix that? How do I destroy the animation instead of just calling :Stop()? Or is there any other mechanic to make the old onimations be ignored?
01 | local Players = game:GetService( "Players" ) |
02 | local player = Players.LocalPlayer |
03 | local character = player.Character |
05 | character = game.Players.LocalPlayer.CharacterAdded:Wait() |
07 | local humanoid = character:WaitForChild( "Humanoid" ) |
08 | local mouse = player:GetMouse() |
09 | local RemoteEvent = game.ReplicatedStorage.RemoteEvent |
10 | local SkyBlastControl = false |
11 | local StormCast = workspace.StormCast |
12 | local StormCastTrack = humanoid:LoadAnimation(StormCast) |
14 | mouse.Button 1 Down:Connect( function () |
15 | SkyBlastControl = true |
18 | StormCastTrack:GetMarkerReachedSignal( "SkyBlast" ):Connect( function () |
19 | if SkyBlastControl = = true then |
20 | print ( "SkyBlastCasten" ) |
25 | mouse.Button 1 Up:Connect( function () |
26 | SkyBlastControl = false |
29 | for _, track in ipairs (humanoid:GetPlayingAnimationTracks()) do |
30 | if track = = StormCastTrack then |
Here is the output:
Necro_las applied edits to script StormScript
- SkyBlastCasten
- unclicked
- SkyBlastCasten (x2)
- unclicked
- SkyBlastCasten (x3)
- unclicked
- SkyBlastCasten (x4)
- unclicked (x5)
- SkyBlastCasten (x9)
- unclicked