How would I go about kicking a ball?

once again not sure if that will work but it might, my pc is on cooldown so i can’t open it today

It is working however it is extremely laggy.
Even in studio it’s laggy so I’m not sure how it would handle in a real server.

strange, never happened to me, are the walls anchored?

Yes. 30000000000000000000000000

That’s probably everything loading in then, it can’t be any of the stuff you just made


The stuff that is circled is the walls
I doubt that would cause lag.

Just a quick additions, assuming your ball is unanchored, roblox added a thing called :ApplyImpulse() which basically gives the ball momentumn, it’s more effective then using body velocity as that might be glitchy unless you constantly change it.

Yeah that’s exactly what I was saying, so i don’t know the cause

Give me a moment to do tests on my main pc

Try this :GetMass() of all the balls parts and sum it together. Then multiply that with velocity and the vector you want the ball to move towards.

Infinate Yeild Possible on 'Workspace.CbrahDev.Waitforchild(“RightFoot”)
(CbrahDev is my main)
That is without GetMass:
I think that this is the reason it’s lagging because I got that warning hundreds of times the second I loaded in to the game.

Have you tried making the event in the ball instead of the foot?

local debounce = false
function kick(hit)
if not debounce then
local players = game:GetService(“Players”)
if players:GetPlayerFromCharacter(hit.Parent) then
script.Parent.Velocity = hit.Parent:WaitForChild(“RightFoot”).CFrame.LookVector * 100
debounce = true
wait(2.5)
debounce = false
end

end

end
script.Parent.Touched:Connect(kick)

How do I type it in my response like it’s a script?
I’m new sorry

do you use r6 or r15 for the game

Player choice. 3000000000000000

"```lua
--put code here
```"

remove the quotations

local debounce = false
function kick(hit)
	if not debounce then
		local players = game:GetService("Players")
		if players:GetPlayerFromCharacter(hit.Parent) then 
			script.Parent.Velocity = hit.Parent:WaitForChild("RightFoot").CFrame.LookVector * 100
			debounce = true
			wait(2.5)
			debounce = false
		end

	end
end
script.Parent.Touched:Connect(kick)

players:GetPlayerFromCharacter(hit.Parent) interesting line I am gonna use that in the future.

I would change a few things, first I would remove change the if statment to players:GetPlayerFromCharacter(hit.Parent) and hit.Parent:FindFirstChild("HumanoidRootPart") I am using the humanoid root part since that is consistent, the right foot might be moved due to animations.

Also the next line has a wait for child, if the player leaves the game it would cause lag as it becomes extra memory.

I would change that line to script.Parent:ApplyImpulse(hit.Parent.HumanoidRootPart.CFrame.LookVector * 100 * script.Parent:GetMass()) This makes the ball move at 100 studs/s

Otherwise looks good

Also critical add in there at the beginning of the script script.Parent:SetNetworkOwner(nil)

Yup that’s my line, basically what it does is it finds the player based on the character instance, found that out a few weeks ago

1 Like