Some background to the code that is not included: the code welds the player and spaceship (a union part) together. The code is supposed to keep the spaceship pointing where the mouse is pointing. The problem is that is the tween service is blocking the velocity or is there another problem.
Here is the code:
while true do wait(0.1) local bodyPart = player.Character:FindFirstChild("LowerTorso") local goals = {CFrame = CFrame.new(bodyPart.Position, Vector3.new(mouse.Hit.X, mouse.Hit.Y * 2, mouse.Hit.Z))} local tween = ts:Create(p, info, goals) tween:Play() game:GetService("UserInputService").InputBegan:connect(function (input, _) -- recognizes input is being given if input.KeyCode == Enum.KeyCode.E then y.maxForce = Vector3.new(math.huge, math.huge, math.huge) y.velocity = (p.Position - mouse.hit.p).unit * 175 print("done") end end) end
Thanks for the Help!
You should not be using a while loop for this task at all as it will lead to stuttery movements. In addition you are connecting a new function to the InputBegin event every loop which is not needed.
For this kind of work you want to be using the RunService.
I would also look at using the following constraints as they are more flexible in general.
You should be setting the expected rotation and directional force on frame render to get a smooth result.
Make sure to set the network ownership this will pass the physics calculation load from the server to the players device. This means they will see the changes first as they are the ones calculating it. Note this does however mean that this can be expoited as the client can now change the physics as will e.g. teleport around the map.
Overall its a trade off between gameplay and game security but you can use sanity checks to help reduce expoitability.
I hope this helps. Please comment if you have any questions related to this post.