Does Roblox count decimal numbers?

I was doing a script to move an object and I tried to be very specific with the ending point so I pasted the current x-axis

 for i = 1,97.396 do
 script.Parent.CFrame = CFrame.new(script.Parent.Position + Vector3.new(.2,0,0))
 wait()
 end

I calculated where it would end and it should’ve been 19.47 but it stopped at 19. I checked and I had the part at position 0,0,0.
So now I’m left wondering if I did something wrong or if Roblox didn’t count the decimal numbers.

You’d need to specify what number to increase by. By default, the increment is 1. Try decreasing it like so;


 for i = 1,97.396,0.01 do
 script.Parent.CFrame = CFrame.new(script.Parent.Position + Vector3.new(.002,0,0))
 wait()
 end

This would make it go slower, however.

Although I wouldn’t recommend needing such a precise number, you should try to keep it as precise as possible.

3 Likes

Also that is not going to be a very smooth movement. Instead you should use the tween service looking something like this.

local TweenService = game:GetService("TweenService");

local TargetPosition = CFrame.new(10,15,0);

local TweenCharacteristics = TweenInfo.new(
	1,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out
);

local Tween = TweenService:Create(
	game.workspace.Part,
	TweenCharacteristics,
	{["CFrame"] = TargetPosition}
);

Tween:Play();

Tween.Completed:Connect(function()
	print("TweenDone");
end)
6 Likes