Basically put, the first time that an animation plays it doesn’t run fire the event.
What I mean:
The first time you try to throw the ball, the animation doesn’t fire the event.
However any time after the first one, it is fired.
I’ve tried connecting the event before the animation plays but it doesn’t get first fired anyways.
But other than that, I have no idea how to fix it.
Before you see my code, it’s on the server because it’s just simpler to have it there if I’m both verifying the attack and tying the animation to the attack.
Code
local anmtr = char.Humanoid:FindFirstChild("Animator")
if anmtr then
local throwA = anmtr:LoadAnimation(rHThrow)
local ev = throwA:GetMarkerReachedSignal("RightHandRelease"):Connect(function()
--prep
local mouseP = gMouse:InvokeClient(plr)
--creation of ball
local bball = lib.createEffectBall(char) --module script that returns a ball parented to character
bball.BrickColor = BrickColor.new("Lime green")
bball.Position = char.RightHand.CFrame.Position - (char.RightHand.CFrame.RightVector*0.35) - (char.RightHand.CFrame.UpVector*0.5)
bball.Transparency = 0.25
--send it towards the mouse
local hit, pos = workspace:FindPartOnRayWithIgnoreList(Ray.new(bball.Position, (mouseP - bball.Position)*2), {bball, char})
if hit then
local d = (pos - bball.Position).Magnitude
local anInfo = TweenInfo.new(d/aOrbSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local anim = tws:Create(bball, anInfo, {Position = pos})
anim:Play()
game.Debris:AddItem(bball, d/aOrbSpeed)
else
bball:Destroy()
end
end)
throwA:Play(0.1)
wait(throwA.Length + 0.1)
ev:Disconnect()
end