-
I change the pivot, but the movement doesn’t seem to notice it changed, maybe it has to be applied in the code or something.
-
The longer I hold the key, the faster the rotation goes, instead of staying at a constant speed.
Yep.
Just tested it for myself, realized that pivots run on a separate CFrame system:
RS.Heartbeat:Connect(function()
if Knuckles then
local x,y,z = FrontKnuckle:ToOrientation()
FrontKnuckle:PivotTo(FrontKnuckle:GetPivot() * CFrame.Angles(x, y - 0.05, z))
end
end)
See if this fix solves the second problem as well.
I’m so sorry
RS.Heartbeat:Connect(function()
if Knuckles then
local x,y,z = FrontKnuckle.CFrame:ToOrientation()
FrontKnuckle:PivotTo(FrontKnuckle:GetPivot()* CFrame.Angles(x, y - 0.05, z))
end
end)
It works now!
But for some reason even having it at 0.05 makes it extremely fast…
Slowing it down would require something like 0.000005, is there a way to fix that?
Something like (1 being really slow as a minimum)
Roblox uses two measurements for angles, radians and degrees.
x, y, z are in radians however 0.05 can be thought of as being in degrees.
we just need to convert 0.05 degrees to radians
the formula for that is:
radians = degrees * pi/180°
0.05 deg = 0.000873 rad | Much smaller
However, Lua has a built-in function to do it for you: math.rad()
Anyways here’s the updated code:
RS.Heartbeat:Connect(function()
if Knuckles then
local x,y,z = FrontKnuckle.CFrame:ToOrientation()
FrontKnuckle:PivotTo(FrontKnuckle:GetPivot()* CFrame.Angles(x, y - math.rad(0.05), z))
end
end)
Hope it helps!
It does the same thing sadly.
Maybe the multiplier has something to do with it, might be increasing it to a bigger number, but I’m not sure.
(Also forgot to mention it still speeds up exponentially the longer I hold it)
Unsure if CFrame allows additive behavior of angles, but see if replacing * with + fixes it:
FrontKnuckle:PivotTo(FrontKnuckle:GetPivot() + CFrame.Angles(x, y - math.rad(0.05), z))
Putting the + made it stop moving
I fully tested it out and figured out the problem, try this for the PivotTo():
FrontKnuckle:PivotTo(CFrame.Angles(x, y - math.rad(0.05), z) + FrontKnuckle:GetPivot().Position)
It was wayyy slower
Finally works!!
Thank you so much
[Hold on, something just happened]
Minor issue again
Might need a way to stop it when it gets to that point (or at 90 degrees)
Yeah, that looks brokey
Use math.clamp(x, min, max) to constrain the motion. If that doesn’t work try wrapping math.rad() around 0 and 90 as those are degree values.
local speed = 0.1
RS.Heartbeat:Connect(function()
local x,y,z = FrontKnuckle.CFrame:ToOrientation()
FrontKnuckle:PivotTo(CFrame.Angles(x, math.clamp(y - math.rad(speed), 0, 90), z) + FrontKnuckle:GetPivot().Position)
end)
Neither method worked, unless I did “wrapping math.rad() around 0 and 90” wrong:
local speed = 0.03
RS.Heartbeat:Connect(function()
local x,y,z = Digit1.CFrame:ToOrientation()
Digit1:PivotTo(CFrame.Angles(math.clamp(x - math.rad(speed, 0, 90), y, z)) + Digit1:GetPivot().Position)
end)
We’ll just leave 0 since 0 degrees = 0 radians, but encase 90 in a math.rad():
local speed = 0.1
RS.Heartbeat:Connect(function()
local x,y,z = FrontKnuckle.CFrame:ToOrientation()
FrontKnuckle:PivotTo(CFrame.Angles(x, math.clamp(y - math.rad(speed), 0, math.rad(90)), z) + FrontKnuckle:GetPivot().Position)
end)
Somehow still nothing.
All I changed was “FrontKnuckle” to Digit1 (I renamed the part label to that)
Did you rename all of the references inside of the LocalScript and Script?
Yep, I’m sure.
--// SERVER (SERVERSCRIPTSERVICE) //--
local REP = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
local remote = REP.FK1
local Digit1 = game.Workspace.RobotArm.Claw.DigitsKnuckles.Digit1
local Digits
local speed = 0.1
RS.Heartbeat:Connect(function()
local x,y,z = Digit1.CFrame:ToOrientation()
Digit1:PivotTo(CFrame.Angles(math.clamp(x - math.rad(speed), 0, math.rad(90)), y, z) + Digit1:GetPivot().Position)
end)
remote.OnServerEvent:Connect(function(plr, state)
Digits = state
end)
I didn’t change a single thing in the client script too.
We keep bumping this topic, want to move this over to DevForum messenger?
Sure, messaging