How can i make this ball attack a player?

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

So basically im remakin an old game called “R.U.N(Or survive the spheres”. I need the balls to attack the players but im not quite sure how id pull this off?

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

My issue is that i have no idea how i would make the balls move towards a player with “AssemblyLinearVelocity”. I dont want them to just move around randomly because thats not as much fun. Heres am example of what i want(Beware that the video is low quality Roblox - Survive the spheres - YouTube)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Like i said. I tried some solutions but none suceeded. Either the ball started going crazy or just speeded up so much it glitched out of the map :expressionless:

There isnt really any code i can provide here since i have no idea how id pull this of. The only line of code is this “.Stepped” event for handling the movment lol

game["Run Service"].Stepped:Connect(function()
     Meta.Ball.PrimaryPart.AssemblyLinearVelocity = -- // Ball is inside a meta table btw.
end)

Any help is appreciated :slightly_smiling_face:

1 Like

Fixed it. Somehow by adding a “task.wait()” it fixed the problem.

Heres the solution if anyone ever needs it

game["Run Service"].Stepped:Connect(function()
			local Plr = GetNearestPlr(Meta.Ball.PrimaryPart.Position)

			if Plr then
				Meta.Ball.PrimaryPart.AssemblyLinearVelocity = (Plr.Parent.PrimaryPart.Position-Meta.Ball.PrimaryPart.Position).Unit*10
			end
		end)

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