How to make this mechanic?

So there’s a soccer game, and there’s a mechanic that when you touch the ball, it flies off to the side you’re looking at. The question is, how can I do that?

5 Likes

It looks like a simple game, so im going to assume it just uses a Touched event, and setting the ball’s velocity with BasePart:ApplyImpulse(), the vector3 being the players humanoidrootpart’s lookvector * 10

there are many more ways to do this, and they are more reliable, but if you just want a simple game like the one you posted, it should be enough

2 Likes

thanks for your help, and can you tell me more if it’s not too much trouble.

1 Like

What else is there to tell?

Summary

This text will be hidden

1 Like

Tween Service ig, you could make it so if the player body touched the ball, then the tween happens.

1 Like

there is no need for tweenservice, apply impulse to the ball, what would he use tweening for?

1 Like

Like what? That’s basically the whole game.

External Media
2 Likes

Wow that’s pretty much what I was trying to achieve, thank you for your help, but how can I improve this script? Like add less delay in touching the ball.

you could change these lines:

bv.Velocity = hrp.CFrame.LookVector * 30 + hrp.CFrame.UpVector * 10
	
	
task.wait(.1)
bv:Destroy()
deb = false

to:

bv.Velocity = hrp.CFrame.LookVector * 30 + hrp.CFrame.UpVector * 10

task.delay(.1, function()
    bv:Destroy()
end)

and removing or deb from the following line:

if not part.Parent:FindFirstChild("Humanoid") or deb then return end
1 Like

How can I make the ball not keep rolling so fast and long?

And if it’s not too much trouble, can we connect in Discord so you can help me if I have problems with the ball in the future.

_jedder

you could use another task.delay, that sets it’s velocity to 0 0 0 after a couple seconds. This should work.

task.delay(2, function()
    ball.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
end)

I’ve added you on discord, keirahela

2 Likes