Right now I'm working on a golf game and I currently don't know why the ball doesn't actually move. This always works the first time I create and script the object but after the first test nothing works. IT'S FRUSTRATING!!!
local Ball = script.Parent local AddVel = Vector3.new(75,150,0) print("Hitting in 3 seconds") wait(3) Ball.Velocity = Ball.Velocity + AddVel print("Hit")
The velocity property of parts can be a bit tricky to control sometimes, especially in unanchored parts. If you want to move the ball we can use something called a BodyMover , in this case BodyForce, which moves the part in world coordinates.
First let's make a force variable
local force = Vector3.new(75,150,0)
Next let's create the BodyForce instance and change its force
local bf = Instance.new("BodyForce") bf.Force=force
Now let's put things together
local Ball = script.Parent local force = Vector3.new(75,150,0) local bf = Instance.new("BodyForce") bf.Force=force print("Hitting in 3 seconds") wait(3) bf.Parent=Ball print("Hit")