How To Make This Script Repeat 10 Times?

local animation = Instance.new(“Animation”)
animation.AnimationId = “rbxassetid://8860557650”

local trackanimation = nil
local playability = true

function playAnimation (animationSource)
	if playability == true then
		local plr = game.Players.LocalPlayer	
		trackanimation = plr.Character.Humanoid:LoadAnimation(animation)

		trackanimation.KeyframeReached:Connect(function()
			print("Animation successfully played!")
		end)
		trackanimation:Play()
	end
end
script.Parent.MouseButton1Click:Connect(playAnimation)
1 Like

Probably should be utilizing for loops xd.

for i = 1, 10 do

end;

Whatever you want to happen 10 times put in the function.

Try something along the lines of

while script.Parent.RepeatValue.Value ~= 10 do
wait(1)
script.Parent.RepeatValue.Value = script.Parent.RepeatValue.Value + 1
-- put ur code here 
end
function ScriptRepeater()
    for i = 1, 10 do
        playAnimation()
    end
end

script.Parent.MouseButton1Click:Connect(ScriptRepeater)