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?
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
if not character then
character = game.Players.LocalPlayer.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local mouse = player:GetMouse()
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
local SkyBlastControl = false
local StormCast = workspace.StormCast -- mudar
local StormCastTrack = humanoid:LoadAnimation(StormCast)
mouse.Button1Down:Connect(function()
SkyBlastControl = true
local hit = mouse.Hit
StormCastTrack:Play()
StormCastTrack:GetMarkerReachedSignal("SkyBlast"):Connect(function()
if SkyBlastControl == true then
print("SkyBlastCasten")
end
end)
end)
mouse.Button1Up:Connect(function()
SkyBlastControl = false
StormCastTrack:Stop()
print("unclicked")
for _, track in ipairs(humanoid:GetPlayingAnimationTracks()) do
if track == StormCastTrack then
track:Stop()
break
end
end
end)
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

3 comments
Can we see the code so we can understand what is happening better?
There it is
Just made some edits that i realized now