local Part = script.Parent -- this is the Part we will move
local newPos = Part.Position + Vector3.new(0,0,8) --the position the Part will go to
local Time = 5 -- the time that the script will take to move the part
local Increment = 3 -- the Part will move 3 studs each time it moves
local Debounce = false
local Diff = newPos - Part.Position -- the difference between the two positions
local Mag = Diff.magnitude -- the distance between the two parts
local Direction = CFrame.new(Part.Position, newPos).lookVector
game.Workspace.FieldMarkers.MyClickDetectorEvent.OnServerEvent:Connect(function()
if Debounce then return end -- end the function if debounce is true
Debounce = true -- make Debounce true so the function can't run
wait(1.5)
for n = 0, Mag, Increment do
Part.CFrame = Part.CFrame + (Direction * Increment)
wait( (Time/Mag) * Increment )
end
Debounce = false -- set Debounce to false so the function can run again
end
)
This script is supposed to make the brick go 8 studs to reach its position, but instead it adds 1 extra stud and I don't know where it added the extra stud and why it adds it.

1 comment
And the positions that are subtracted are not decimals they are whole numbers so that's not the problem