You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make this as smooth as possible -
What is the issue? Include screenshots / videos if possible!
In my game i have a ship system which i am using Bodyposition to move the ship. everything is working fine except sometimes there is a moment where the ship stops moving and then a few seconds later it continues moving.
https://gyazo.com/740c422f16c270b3a2d000ed8d62f1cb -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have done my best to research on this but i did not find anything. and i tried using Bodyvelocity in the past but it was worse i dont know if it was something to do with my code.
while wait() do
script.Parent.MainPart.A1.WorldPosition = Vector3.new(script.Parent.MainPart.A1.WorldPosition.X,workspace.Terrain.Water.Position.Y+.1,script.Parent.MainPart.A1.WorldPosition.Z )
script.Parent.MainPart.A2.WorldPosition = Vector3.new(script.Parent.MainPart.A2.WorldPosition.X,workspace.Terrain.Water.Position.Y+.1,script.Parent.MainPart.A2.WorldPosition.Z )
if DD ~= nil and DD.Occupant ~= nil and Bg ~= nil and Bp ~= nil and script.Parent:FindFirstChild("MainPart") ~= nil then
if DD.Steer ~= 0 then
y = y+((DD.Steer*-Speed)/750)
script.Value.Value = script.Value.Value:Lerp(Vector3.new(0,0,-DD.Steer/7),.1)
Bg.CFrame = CFrame.Angles(0,y,script.Value.Value.Z )
else
script.Value.Value = script.Value.Value:Lerp(Vector3.new(0,0,0),.1)
Bg.CFrame = CFrame.Angles(0,y,script.Value.Value.Z )
end
local v = false
if DD.Throttle ~= 0 and v == false then
local NewSpeed = Speed
local D = Bp.Position+ (script.Parent.MainPart.CFrame.LookVector*((Speed*DD.Throttle))/25)
local v = false
local Base = script.Parent.MainPart.CFrame*CFrame.new(0,-script.Parent.MainPart.Size/2,DD.Throttle* script.Parent.MainPart.Size.Z/2*-1)
local R1 = Base.p
local R2 = Base.lookVector*200*DD.Throttle
local ray = Ray.new(R1,R2)
local part,pos = workspace:FindPartOnRayWithIgnoreList(ray,{script.Parent,workspace.DebreeFolder,DD.Occupant.Parent})
if (part ~= nil and part.CanCollide == true and (R1-pos).Magnitude <=25) then
v = true
end
if v == false then
Bp.Position = Vector3.new(D.X,PosY,D.Z)
end
end
else
script.Value.Value = script.Value.Value:Lerp(Vector3.new(0,0,0),.1)
Bg.CFrame = CFrame.Angles(0,y,script.Value.Value.Z )
if script.Parent:FindFirstChild("MainPart") ~= nil then
if script.Parent.MainPart.Velocity.Magnitude ~= 0 then
script.Parent.MainPart.Velocity = script.Parent.MainPart.Velocity*.95
end
end
end
end