✓ Accepted answer
Here is what it means:
math.ceil means that it rounds up to the nearest whole number. For example:
local num = 0.5
print(math.ceil(num))
The above would print out 1 as 1 is the nearest whole number when rounding up.
math.abs means that it gives the absolute value of the number. For example:
local num = -0.5
print(math.abs(num))
The above would print out 0.5 as 0.5 is the absolute value of -0.5. Simple math lol
script.Parent means that the script in which you are writing will find the parent of it. For example:
If you add a part and add a script inside a part and type the following code:
script.Parent.Transparency = 0.5
Then you will see that the part in which the script you just wrote is in will become half-transparent as the parent of the script is the part.
So what this script means is:
while true do
if math.ceil((script.Parent.part.Position-script.Parent.anchor.Position).Magnitude) >= math.abs(script.Parent.part.PrismaticConstraint.TargetPosition) then [[--If the position of the part minus the position of the anchor, when rounded up is greater than or equal to the absolute value of the target position of the PrismaticConstraint in the part, then--]]
script.Parent.part.PrismaticConstraint.TargetPosition = - script.Parent.part.PrismaticConstraint.TargetPosition [[--The TargetPosition of the PrismaticConstraint will be equal to the negative value of the TargetPosition of the PrismaticConstraint--]]
wait(1)
end
wait()
end
Hopefully this helped! Please mark it as an answer if it helped as it took a lot of time to write!
7 comments
bruh math.ceil is just rounding
also i think there is a lerp function for that
start * (1 - t) + end * t
where t is a number between 0 to 1
and then just iterate that
that isnt how this specific script works and i apologise for not explaining that. I think it relies on some built in mechanic tho(i cant confirm this, as i am neither good at constraints nor at maths), and not just pure maths.
for that i would recommend u look up roblox lerping