# Tennis Ball Help

So I’m trying to make a tennis ball. So when you touch it, it will move forward. How would I do this? I’ve been having trouble and now I don’t really know where to start…

3 Likes

Maybe un-anchor it? (Unless it is already un-anchored!)

If I do this it will just roll. I have a script, but it doesn’t work so I need help with a new script that will work.

Can I see the script? I will look over it to see what might be going on.

So, assuming your using Roblox physics just do some basic math to get the velocity that you would like. This is to move the ball of course, however, before you do this you need to actually hit the ball. I would suggest using a touch event. This way every time the ball touches the racket it would go in the direction that you applied the vector forces to.

Umm sure, but it doesn’t work well even if you fix it because it won’t drop in a curve.
Script:

``````local Speed = 100
local Length = 1

script.Parent.Parent.Ball.Touched:Connect(function(partTouched)
local Character = partTouched.Parent

local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = script.Parent.Parent.Ball
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity.Velocity = Character.HumanoidRootPart.CFrame.LookVector * Speed

local Debris = game:GetService("Debris")
end)``````

You could use some basic calculus to calculate the trajectory of the ball.

I’m not sure what that is can you explain or give me an example? I’m not that advanced

If you want when a player hits it, then it will move in a curve, try using CFrame!

Can you give me an example please I’m not sure how to implement this.

My suggestion is CFrame. Although you would have to continue walking into it.

1 Like

CFrame basically moves an item. For example, here’s a script using CFrame.

while true do
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0.0,0.1,0.0)
wait()
end

This script makes a part move in a loop!

Okay thanks! But even if I do this my script will still be broken…

Remove everything except script.Parent.Parent.Ball.Touched:Connect(function(partTouched) and add the CFrame part instead! Also, play around with the CFrame settings. The one used in my example will turn a part around in a circle, if you want it to curve mess with the numbers!

1 Like

So I tried messing around with the numbers, but it just rotates. It doesn’t move…

Let me see if I can make you a working script.

I’m sorry for rushing, but you withdrawn you post twice already so I’m not sure if you’re finished or not…

i know how to do this, make a vector force inside of a part.
ontouched you can enable it
its kinda brute force, but it gets the job done!

So I tried doing something similar, but it doesn’t work.
Script:

``````local Speed = 100
local Length = 1

script.Parent.Parent.Ball.Touched:Connect(function(partTouched)
local Character = partTouched.Parent

local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = script.Parent.Parent.Ball
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity.Velocity = Character.HumanoidRootPart.CFrame.LookVector * Speed

local Debris = game:GetService("Debris")