I am trying to make a automatic moving helicopter this is my script
while wait() do
script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame()*CFrame.new(0,0,0-1))
end
The problem is its not smooth
I am trying to make a automatic moving helicopter this is my script
while wait() do
script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame()*CFrame.new(0,0,0-1))
end
The problem is its not smooth
I tried but the problem is if anything hits the model it changes the orientation or the position of the model
Unfortunately since you are incrementing it’s position manually you are going to be limited by the server’s physics rate.
If you want to avoid relying on the wait
function you could bind it’s movement to a runservice event:
local vehicle = script.Parent
local speed = 30 -- studs per second
game:GetService("RunService").Heartbeat:Connect(function(dt) -- 'dt' is the time in seconds since the last physics frame, we can use it to more accurately calculate the vehicle's position WRT time.
vehicle:SetPrimaryPartCFrame(vehicle.PrimaryPart.CFrame * CFrame.new(0, 0, -1 * speed * dt))
end)
omg its sooo much smoother now thanks so much!!
sorry but it looks smooth when i run it but it looks weird when i play it:
That’s because the movement is being dictated by the server and in an online game it has to replicate to all clients, and the small delays can cause that staggering. Running the CFrame code on the client would fix it, but if you’re planning to have players ride in the vehicle I might actually recommend using bodymovers as mentioned before.
Follow up on this tutorial:
Basically you weld every part of the model to the main part and tween that instead.
In addition to that, you can set each parts network owner to thee client by using:
Part:SetNetworkOwner(playerhere)
https://developer.roblox.com/en-us/api-reference/function/BasePart/SetNetworkOwner
I made a moving helicopter like this. I used TweenService.
Here how it works:
This strategy allows the server to dictate the movement of the helicopter without using any physics. All physics are on the client, so this avoids a lot of networking lag. Here’s a video of what it looks like:
Edit: Forgot to mention why use AlignPosition. Making the actual helicopter’s movement based on physics on the client smooths out a lot of the choppiness. When you tween something on the server, it will not appear smooth to clients. The AlignPosition constraint fills in the gaps so that the helicopter can still have smooth movement.
The problem with body mover is players can stop the model from moving by pushing or something
Iam just a basic builder and I don’t know much about scripting but thanks!
You should use TweenSercice
local tweenService = game:GetService("TweenService")
localHeliMoveTween = tweenService:Create(Helicopter.Basepart),TweenInfo.new(3,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Position = TargetPart.Position})
localHeliRotateTween = tweenService:Create(Helicopter.Basepart),TweenInfo.new(3,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut),{Rotation = TargetPart.Rotation})
HeliMoveTween:Play()
HeliRotateTween:Play()