Problems on tweening while raycasting

When I trigger the prompt, I want the block to move left, right, front, or back. But sometimes the direction is not correct, and it even stops working!
Link to video

proximity.Triggered:Connect(function(plr)
	print(debounce)
	if debounce == false then
		debounce = true
			for i = 1,4 do
				print(i)
			local rayDirection = Directions[i] - RayOrigin
		
				local raycastParams = RaycastParams.new()
				raycastParams.FilterDescendantsInstances = {cube:GetChildren()}
				local raycastResult = workspace:Raycast(RayOrigin, rayDirection, raycastParams)
				print("Cast")
					
				if raycastResult then
					if raycastResult.Instance.Parent:WaitForChild("Humanoid") then
						print("Through")
						print(raycastResult.Instance)
						local tween = tweenservice:Create(cube,tweeninfo, {CFrame = CFrame.new(cube.Position) * movements[i]})
						tween:Play()
						print("Tween")
						tween.Completed:Wait()
						for _,v in pairs(cube:GetChildren()) do
							if v:IsA("BasePart") then
								v.CFrame *= movements[i]
							end
						end
					end
				else print("Not through")
				end
			end
		debounce = false
	end
end)