How do i stop a sphere from rolling when players collide with it

Hello, I want to know how to make a sphere not roll around when a player collides with it

3 Likes

stop moving how? anchor itself entirely or just reset velocity?

1 Like

I have a soccer game, so ball the ball can’t be anchored. What the problem is, is that when you collide and dont kick it with the ball it rolls away I hope you get what I mean

1 Like

Use a cube that looks like a ball then, or make a BodyVelocity that makes the velocity 0, 0, 0. Maybe you can make the ball heavy to make pushing ineffective.

1 Like

What is the body velocity going to do?

1 Like

You can try use the VectorForce to stop the ball rolling without anchoring it.

And i don’t know if it’s going to work but you can also try to set the AssemblyLinearVelocity to
Vector3.zero

2 Likes

Maybe its density because the higher mass = how hard it is to push the ball.

Hi, kindly review and try the code below and test it. You would need to adjust and change some variables depending on where your ball is located inside the game.

I did use a anchor, but only briefly; so that the ball won’t move for a 3 second wait when being touched:

local ball = script.Parent
local ismoving = false

ball.Touched:Connect(function(part)
	if ball.AssemblyLinearVelocity.Magnitude > 0 then -- checks to see if the ball is moving
		ismoving = true
	end
	local areumodel = part.Parent:FindFirstAncestorOfClass("Model")
	local aruhuman = areumodel:FindFirstChild("Humanoid") or areumodel:WaitForChild("Humanoid")
	if aruhuman then
		if ismoving  == true then
			ball.Anchored = true
			wait(3)
			ball.Anchored = false
			ismoving = false
		end
	end
end)

It doesn’t bounce back as a realistic soccer ball, but it does achieve the purpose you wanted: making the ball stop rolling when the player touches it. Also, alter the delay based on how long you want it to stop moving when the player touches it.

You can make players not able to collide with the sphere using Collision Groups.

Here is a tutorial:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.