Hi,
my issue is simple, I found bug, that when I try to rotate servo with limit enabled, it can still go in path, where is the rotation out of limit, and it get stuck on the limit.
To alter a part’s CFrame in a way that causes it to rotate
for example ,
would be done by utilizing RunService.Heartbeat , as that will run after physics simulation and fires every frame. To rotate a part indefinitely ,
we will use a local script in starterPlayerScripts :
local part = workspace.Part
game:GetService("RunService").Heartbeat:connect(function(dt)
--changing math.Rad(5.5) to a lower number would decrease the speed at which this would happen
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(5.5)*dt*60, 0)
end)
Rotating multiple parts asynchronously
you could do this to rotate multiple parts
local folder_containing_parts = workspace.Folder2
local children = folder_containing_parts:GetChildren()
for _,kid in pairs (children) do
if kid then
game:GetService("RunService").Heartbeat:connect(function(dt)
kid.CFrame = kid.CFrame * CFrame.Angles(0, math.rad(1)*dt*60, 0)
end)
end
end
And to move a part to another position , as @return_end1 modified my script on another post,
local runService = game:GetService("RunService")
local destinationCFrame = workspace.part2.CFrame
local speed = 2
local heartbeat do --Pushing it into a do block for clean syntax
heartbeat = runService.Heartbeat:Connect(function(step)
script.Parent.CFrame = script.Parent.CFrame:Lerp(destinationCFrame, step/speed)
if script.Parent.CFrame == destinationCFrame then
heartbeat:Disconnect()
return
end
end)
end
you say, that I may use cframes, that is great solution, but not when i am moving mesh parts, and i need to rotate every single canon, bec it will cause lag, specialy, when i have more, than 1 models with guns
No, it will not cause lag as it is done on the client and is using heartbeat .
Meaning that the quality depends on the machine, eg. the person’s own computer
and on top of that it’s not done by the server for every client, instead it is done separately per client (as it would be a local script in StarterPlayerScripts), with what quality is decided by the machine processor, plus since we are using Heartbeat , it will fire every frame and appear smooth