How do i make a system that plays an animation and drops the ball at the same time?

How do i make a system where a player drops the ball and plays an animation? I’ve tried different scripts but none seem to do it into the tool.

I’m creating a new game called Bowling Masters and i’m unsure how to create this type of effect. Help would be good. VFX is also okay.

Exactly which part are you having a problem with? Dropping the ball and having it roll down the lane, or the animation of the player launching the ball down the lane? From your question, I’m assuming you want to play the animation and do the ball drop at the same time.

Once the animation is loaded, there is a property of the AnimationTrack called Length. This property is the length of the animation. What you will probably want to do is spawn a delay function with the wait time being the length of the animation and then drop the ball at the end of it. Of course, this depends on your specific animation.

local playerService = game:GetService("Players")
local localPlayer = playerService.LocalPlayer
local char = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local human = char:WaitForChild("Humanoid", 10)
local animator = human:WaitForChild("Animator", 10)

-- Loads an animation track.
local animationTrack = animator:LoadAnimation(--Animation to Load--)

delay(animationTrack.Length, function()
	--Drop Ball--
end)

Place this in with your local scripts. If your ball is a tool, then place this under the tool class item in Explorer. This is by no means a complete script, but something to get you started as you will need to get input from the player to start it.

This should get you started. Good luck.

EDIT: Added more information.

Where do i place this script?`

Place it as a LocalScript in StarterPlayerScripts. Make sure it’s a LocalScript

It’s a local script you would place where you put your other local scripts at. If you have your ball as a tool, then it would be under the tool class in Explorer. This is by no means a complete script, so you will need other things such as mouse clicking and such to make it work.

But im a beginner scripter. ```

How is your ball defined? Is it a tool or something else?

Tool. It’s a tool in Starterpack

Then that script would be in your tool. You could do something like this (Server Script):

-- Critical Things
local toolInstance = script.parent
local handle = toolInstance.Handle
local head = toolInstance.Parent:FindFirstChild("Head")
local human = toolInstance.Parent:FindFirstChild("Humanoid")

-- Event Connections
local activateConn = nil
local deactivateConn = nil
local equipConn = nil
local unequipConn = nil
local destroyConn = nil

-- Some settings
local velocity = 30.0
local activationRate = 5.0
local equipped = false
local debounce = true

-- Load animation
local animator = human:FindFirstChild("Animator")
local animationTrack = animator:LoadAnimation(--Animation Track--)

-- Called when the tool is equipped.
equipConn = toolInstance.Equipped:Connect(function()
	equipped = true
end)

-- Called when the tool is unequipped
unequipConn = toolInstance.Unequipped:Connect(function()
	equipped = false
end)

-- Called when the tool is activated.
activateConn = toolInstance.Activated:Connect(function()
	if not equipped then
		return
	end
	if debounce then
		debounce = false
		local ball = handle:Clone()
		ball.Name = "BowlingBall"
		handle.Transparency = 1
		local vector = head.CFrame.LookVector
		ball.Velocity = vector * velocity
		animationTrack:Play()

		-- Add the ball to the workspace at the end of the animation.
		delay(animationTrack.Length, function()
			ball.Parent = game.Workspace
		end)

		-- Return ball to player's hand and ready for
		-- another launch.
		delay(activationRate, function()

			debounce = true
			handle.Transparency = 0
		end)
	end
end)

-- Called when the tool is deactivated.
deactivateConn = toolInstance.Deactivated:Connect(function()
	if not equipped then
		return
	end
end)

-- Called when the tool is destroyed.
destroyConn = toolInstance.Destroying:Connect(function()
	equipConn:Disconnect()
	unequipConn:Disconnect()
	activateConn:Disconnect()
	deactivatConn:Disconnect()
	destroyConn:Disconnect()
end)

This is a basic server script. You will need to modify it to suit your purposes. There’s probably going to be errors in this since I wrote this on the fly.