How to stop soccer ball from being kicked outside walls?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Stop players from kicking the ball outside of the boundaries

  1. What is the issue? Include screenshots / videos if possible!

since the ball attatches to the player (like Kick Off,) the player who has the ball can walk up to a wall (the ball is non collideable) and if they kick the ball, the ball will go outside of the boundary because the ball is outside of the wall when it is attatched

like this

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried to CFrame the ball to the HumanoidRootPart before it is launched but this makes the ball warp behind the player which messes up the accuracy of the shot.
	local part = script.Parent
	part.CanCollide = true
	if part:FindFirstChild("ManualWeld") then
	local Character = player.Character
	local bf ="BodyForce",script.Parent)
	if part:FindFirstChild("ManualWeld") then
	local Firing = Character.Humanoid:LoadAnimation(script.Anim)
	bf.Force= Character.HumanoidRootPart.CFrame.lookVector*3000 +,4000,0)
	local S ="Sound",part)
	S.SoundId = "rbxassetid://4458219865"
	S.PlaybackSpeed = 1
	S.Volume = 0.5
	Character.HumanoidRootPart.Anchored = true
	script.BallShotCooldown.Value = true
	script.BallTaken.Value = false
	script.BallHolder.Value = ""
	Character.HumanoidRootPart.Anchored = false
	part.Trail.Color ={ -- a color sequence shifting from white to blue, Color3.fromRGB(255, 255, 255)),, Color3.fromRGB(239, 184, 56))
	script.BallShotCooldown.Value = false
1 Like

Can’t you just turn on collision for it?

[Collision groups] are very useful in this case, in which you are able to set players to not collide with a barrier for the ball.


I want both the ball and the player to be stopped by the barrier

this messes up the player’s movement

Create a bigger hit box around the character, this might solve your issue.

Set the ball to Massless in it’s properties

1 Like

Collision groups are your friend here! This guy has given you your answer you are looking for!
How you would do this is you would make a collision group for your ball, which needs can collide true. Make the ball able to collide with itself and set the walls to the same collision group, but make the default collision group not collide with the new collision group
(I made a few gramatical/logical errors in this, but I hope you get what I’m trying to say, of course I recommend you research how to use collision groups to better understand them and you should be able to fix your problem!)