My code:
local cd = 10
local initial = 1
local animator = nil
local ws = script.Parent.Parent.Speed.Value
function throw()
local towere = game.Workspace.Towers:GetChildren()
local tower = towere[math.random(1, table.getn(towere))]
local rock = script.Parent.Handle:Clone()
local sound = script.Sound:Clone()
sound.PlayOnRemove = true
sound.Parent = rock
rock.Name = "Rock"
local bodyGyro = Instance.new("BodyGyro")
bodyGyro.Parent = rock
bodyGyro.D = 500
bodyGyro.P = 1000
bodyGyro.MaxTorque = Vector3.new(3999999947964416, 399999991808, 400000001507328)
local bodyForce = Instance.new("BodyForce")
bodyForce.Parent = rock
bodyForce.Force = Vector3.new(0, rock:GetMass() * game.Workspace.Gravity, 0)
rock.Velocity = -1 * (rock.Position - tower.PrimaryPart.Position)
rock.Parent = game.Workspace
rock.Position = script.Parent.Handle.Position
script.Parent.Parent.Speed.Value = ws
repeat
wait()
until (rock.Position - tower.PrimaryPart.Position).Magnitude < 5
rock:Destroy()
if tower then
tower.Stunned.Value = true
end
end
repeat
wait()
until script.Parent.Parent.Parent == game.Workspace.Enemies
initial = os.clock()
while true do
repeat
wait()
until os.clock() - initial > cd
if table.getn(game.Workspace.Towers:GetChildren()) ~= nil then
ws = script.Parent.Parent.Speed.Value
script.Parent.Parent.Speed.Value = 0
local Humanoid = script.Parent.Parent.Humanoid.Animator
local anim = Humanoid:LoadAnimation(script.Animation)
print(anim)
anim.Priority = Enum.AnimationPriority.Action
anim:Play()
wait(1.05)
initial = os.clock()
throw()
wait(0.3)
end
end
